how to add smothing to the PUN photonView transform sync

edited February 2013 in DotNet
I was looking through the PhotonView.cs to try and find where it does the syncing of the position and rotation. I couldn't find anyplace so i was wondering if there is a certain spot i should look to add smoothing to it or should i just make a script that updates a public transform to the objects transform and do the smoothing in that script instead of where photon view does the transform by default?


  • You can sync (parts of) the Transform OR your own data. For the latter, you need to do a script and drop it to the "Observed" property of a PhotonView.

    Used in the "Smooth Moves" paragraph of the tutorial: ... o_Tutorial
  • I did basically what the tutorial shows, only problem is im doing movement animation based and the smoothing it like this seems to make the animation movement not work and only the smoothing so it looks like the player is moving slow and then when the animations stops still slides alot to reach the final spot, how can I do smoothing but not keep the animation root movement from not working at all.
  • Well i found out how to get smoothing working really good with the animator animation based movement
    void OnAnimatorMove()
    Vector3 newPos = transform.position - avatar.rootPosition;
    transform.position -= newPos;

    if (!view.isMine)
    correctPos -= newPos;
    transform.position = Vector3.Lerp(transform.position, correctPos, Time.deltaTime * smooth);

    with the OnAnimatorMove callback you are taking control of the root motion of the animator compontent. if you leave this blank but still have the function in your monobehaviour you wont move. To make sure you still move i get the difference between the current position and the animations position. At first i added this to the position but then everything moved backwards so i then subtracted it then everything worked. To keep the smothing from smothing to a static place when the character is moveing i also update the correctPos.
  • What is correctPos here? Where it was assigned?