- Home /
Why do other players have stuttering / laggy movement in Photon?
Why is it with Photon the other players movement is extremely stuttering, like an elastic band effect? The player is a RigidBody2D if that helps
Network player script:
public void Start()
{
GetComponent<SmoothSyncMovement>().enabled = true;
}
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.isWriting)
{
//We own this player: send the others our data
stream.SendNext(transform.position);
}
else
{
//Recieve other player
realPosition = (Vector3)stream.ReceiveNext();
}
}
//We lerp towards this
public void Update()
{
if (photonView.isMine)
{
}
else {
Vector3 targetPos = new Vector3(369.1f, -188.9f, -0.1f);
rb2D.position = Vector3.Lerp(transform.position, targetPos, 0.1f);
}
}
}
Player movement script:
void Update () {
Vector3 targetPos = new Vector3(369.1f, -188.9f, -0.1f);
transform.position = Vector3.Lerp(transform.position, targetPos, 0.001f);
}
Comment