Other players have flashing / stuterring movement
Hi all, was just wondering if someone could help with this issue. My own player moves fine, but the other players seem to be flashing and stuttering a lot. Here is the code that constantly moves the player:
public void Update () {
Vector2 playerMovement = rb2D.position + velocity * Time.deltaTime;
rb2D.MovePosition(playerMovement);
}
And then below I have this:
void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.isWriting)
{
// We own this player: send the others our data
stream.SendNext(transform.position);
}
else
{
// Network player, receive data
this.correctPlayerPosition = (Vector3)stream.ReceiveNext();
}
}
Any help? Thanks
public void Update () {
Vector2 playerMovement = rb2D.position + velocity * Time.deltaTime;
rb2D.MovePosition(playerMovement);
}
And then below I have this:
void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.isWriting)
{
// We own this player: send the others our data
stream.SendNext(transform.position);
}
else
{
// Network player, receive data
this.correctPlayerPosition = (Vector3)stream.ReceiveNext();
}
}
Any help? Thanks
0
Comments
-
Please check DemoSynchronization demo for various techniques for smoothing synchronized positions.
In your code correctPlayerPosition assigned with synchronized position but never used.0 -
Thanks, i'm using your SmoothSyncMovement.cs script, however, even though the other player moves correctly, the movement is still quite choppy. Any help? Thanks
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().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();
}
}
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 move script
void Update () {
Vector3 targetPos = new Vector3(369.1f, -188.9f, -0.1f);
transform.position = Vector3.Lerp(transform.position, targetPos, 0.001f);
}
Thanks0 -
Nevermind, I think I have finally been able to fix it0
-
I'm struggling with the same problem. Other players gameobjects are flashing but movement is quite smooth. Do you have any tips to correct that?0
-
What does flashing mean?
0