Quantcast
Channel: Photon Server — Photon Engine
Viewing all articles
Browse latest Browse all 1557

Sync player transform

$
0
0
Hi everyone, I'm getting stuck since 3 weeks with this sync over photon.

There is the problem :



This is not my screen but that's exactly whats happens in my game.
I searched everywhere to move on but I'm starting to give up ...

Well, I tried many script ( lerp, extrapolate, smooth move, this one,) Ive wacth many video on youtube about this topic, and I know that this topic has been treated many times but I just dont understand why the result is always the same :[
I have already asked for help on the net but it was not very beneficial : https://answers.unity.com/questions/1447362/photon-syncing.html?childToView=1449501#comment-1449501

What I managed to synchronize (it seems to me) is the rotation.

The best rendering I have for the moment is with this script :
    private void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            stream.SendNext(transform.position);
            stream.SendNext(transform.rotation);
        }
        else
        {
            TargetPosition = (Vector3)stream.ReceiveNext();
            TargetRotation = (Quaternion)stream.ReceiveNext();
        }
    }
    private void SyncMove()
    {
        transform.position = Vector3.Lerp(transform.position, TargetPosition, 1f);
        transform.rotation = Quaternion.RotateTowards(transform.rotation, TargetRotation, 500 * Time.deltaTime);
    }
Thank

Viewing all articles
Browse latest Browse all 1557

Trending Articles