- Home /
Update position via state syncronization results in weird movement.
Hello,
This is my first multiplayer project and this might be a basic question.
I am using PUN (Photon Unity Networking) but it has a very similar worflow as the unity networking.
I have characters with animation, character controller and third person script attached. Everything runs but the state syncronization.
I have photon View attached on parent and each child and draged the transform component to the observe field, also chosen Unreliable as Observe option.
I open 2 instances of the game (run 2 games, join and start moving the character), I see strange movement (like shaking, going back and fort so fast) in the second window.
I need some directions of what to correct or search at least. Thanks
Not exactly an answer, but every project I've done that uses networking I've had to avoid the view/observer pattern because networking is just more complicated than that simplistic channel leads you to believe.
I'd try using the [RPC] interface in PUN and implementing your own smoothing/dead reckoning.
@$$anonymous$$ortoc according to my knowledge, The RPC calls are used for a different purpose than State syncronization. I need to Update the position at every frame. So far the observe channel is the only method available.
I am using the callback function:
void OnPhotonSerializeView(PhotonStream stream, Photon$$anonymous$$essageInfo info)
{
if (stream.isWriting)
{
stream.SendNext(transform.position);
stream.SendNext(transform.rotation);
}
else
{
this.correctPlayerPos = (Vector3)stream.ReceiveNext();
this.correctPlayerRot = (Quaternion)stream.ReceiveNext();
}
}