PUN2 - Crazy Bone Jitter

Options
I have no idea how to fix this. It seems like two different rotations are getting sent over the network. I have logged the Vector3 position and weights that are getting sent over the network in FixedUpdate, Update, and Late update. Its always the same so nothing in this script seems to be overwritting the values.

Here is a gif showing the problem.

public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) //this function called by Photon View component
        {
            if (stream.IsWriting && GetComponent<PhotonView>().IsMine == true)
            {
                stream.SendNext(currentLookPosition);
                stream.SendNext(_currentHeadWeight);
                stream.SendNext(_currentbodyWeight);
            }
            else
            {
                currentLookPosition = (Vector3)stream.ReceiveNext();
                _currentHeadWeight = (float)stream.ReceiveNext();
                _currentbodyWeight = (float)stream.ReceiveNext();
                SetLookAtPosition(currentLookPosition, _currentHeadWeight, _currentbodyWeight);
            }
        }
void LateUpdate()
        {
            if (GetComponent<PhotonView>().IsMine == false)
            {
                if (_updated == false)
                {
                    _updated = true;
                    GetComponent<vThirdPersonInput>().onLateUpdate -= this.UpdateHeadTrack;
                }
                SetLookAtPosition(currentLookPosition, _currentHeadWeight, _currentbodyWeight);
            }
        }

Any thoughts or suggestions are welcome. I'm on my last leg with this. I even tried sending the actual quaternion rotations and that ends up with the same result.

Comments

  • wesleywh
    wesleywh
    edited April 2020
    Options
    Okay that image isn't working so here is the link to the gif

    https://i.imgur.com/3a0GEsS.gif

    I meant to say in the original post I was checking the currentLookPosition, _currentHeadWeight, _currentbodyWeight. Being received over the network and it is correct. There isn't anything else modifying these values.
  • wesleywh
    Options
    I was able to solve this thanks to some outside help. The underlying problem here is this is a combination of setting bone rotations, IK, and animations all working together. So IKs seem to overwrite things that are happening here. Here is a little hack that was shown to me that makes bone rotations as smooth as butter.
    private bool updateIK = true;
    ...
    ...
    void LateUpdate()
            {
                if (GetComponent<PhotonView>().IsMine == false && updateIK == true)
                {
                    if (_updated == false)
                    {
                        _updated = true;
                        GetComponent<vThirdPersonInput>().onLateUpdate -= this.UpdateHeadTrack;
                    }
                    SetLookAtPosition(currentLookPosition, _currentHeadWeight, _currentbodyWeight);
                   updateIK = false;
                }
            }
    void FixedUpdate()
    {
        updateIK = true;
    }
    

    So as you can see the only thing that I changed was adding the "updateIK"