synchronize the rotation
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on PUN.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
synchronize the rotation
chucky831
2020-03-02 10:27:29
Hi everyone, I'm starting with Photon. I wanted to understand how I can synchronize a rotation. In my game I have 2 players who rotate their weapon in the direction of the mouse. This is the code I made for the single player. I should do a PUN function for rotation so that each player sees where the other is pointing. How should i do?
void Update()
{
mousePos = Camera.main.ScreenToViewportPoint(Input.mousePosition);
posScreen = Camera.main.WorldToViewportPoint(gunPivot.position);
mousePos.z = 0;
Vector3 dir2 = (posScreen - mousePos).normalized;
gunPivot.rotation = Quaternion.LookRotation(Vector3.forward, mousePos - posScreen) * Quaternion.Euler(0,0,90);
Debug.DrawRay(gunPivot.position, dir2 * 10, Color.red);
}
Comments
Just slam a PhotonView and TransformView on your Weapon gameObject.
https://doc.photonengine.com/en-us/pun/v2/demos-and-tutorials/pun-basics-tutorial/player-networking
but and is the child of an object that moves I have to apply the photon view to both the player and the child?
Back to top