I have been trying to fix this for about a week, and i've asked on Unity answers but haven't had any help. For some reason, the other player has stuttering / laggy movement on my player's screen. Please could someone tell me how to fix it, I would appreciate it a lot. Here is the code to move the player (simplified):
And the code to view the other player:
I have a photon view and the player is a Rigidbody2D
Thanks a lot!
Code:
public Rigidbody2D rb2D;
void Update () {
Vector3 targetPos = new Vector3(369.1f, -188.9f, -0.1f);
rb2D.transform.position = Vector3.Lerp(rb2D.transform.position, targetPos, Time.deltaTime * 0.06f);
}
And the code to view the other player:
Code:
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.isWriting)
{
//We own this player: send the others our data
stream.SendNext(rb2D.transform.position);
stream.SendNext(rb2D.transform.rotation);
}
else
{
//Recieve other player
realPosition = (Vector3)stream.ReceiveNext();
}
}
I have a photon view and the player is a Rigidbody2D
Thanks a lot!