MasterClient not in sync

Im trying to get these two cubes to move at the same time on all clients screens. It works fine on the clients screen but not on the MasterClients screen. MasterClient moves hes cube before the client does. How can i fix this issue?

[code2=csharp]void OnJoinedRoom()
{
if(PhotonNetwork.isMasterClient)
{
_myPlayer = PhotonNetwork.Instantiate("Player1",new Vector3(-5,0,0),Quaternion.identity,0);

StartCoroutine(MovePlayers(15.0f));
}
else
{
_myPlayer = PhotonNetwork.Instantiate("Player2",new Vector3(5,0,0),Quaternion.identity,0);
}
}

IEnumerator MovePlayers(float wait)
{
yield return new WaitForSeconds(wait);

if(PhotonNetwork.isMasterClient)
{
photonView.RPC("UpdateMovement",PhotonTargets.AllBuffered);
StartCoroutine(MovePlayers(2.0f));
}
}

[RPC]
void UpdateMovement()
{
_myPlayer.transform.position = new Vector3(_myPlayer.transform.position.x,_myPlayer.transform.position.y + 1,_myPlayer.transform.position.z);
}[/code2]

And i observe the cubes with this:
[code2=csharp]private Vector3 correctPlayerPos;

void Update()
{
if (!photonView.isMine)
{
transform.position = this.correctPlayerPos;
}
}

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.correctPlayerPos = (Vector3)stream.ReceiveNext();
}
}[/code2]

2ugdr8m.jpg

Comments

  • There will always be a slight delay. How obvious this is, depends on your ping time.
    You can hide lag a bit with various techniques but none is perfect.
    Check out the demo "Synchronization" in the PUN package to get an idea what's possible.
  • Yes i know. But i just want it to be sync on the clients screen, not across the network. How could i do that?
  • If player A moves box b1 and B on the other machine moves b2, then you can't. When A moves, there is a (network) delay until B notices that b1 moved.
    If they move synchronously on one client, this might be a bug where key-input is applied to both boxes locally.