Hello!
Im using Unity’s animation rigging package to create head look and spine control for FPS controller which is controlled by position of the rig targets. So according to that Im moving rig targets, according to players body and syncing it to all players like in this photo:
Here is the code:
void LateUpdate() //animation rigging
{
if (!PV.IsMine)
return;
headAngleY += mouseY;
headAngleY = Mathf.Clamp(headAngleY, 0, 140); //Vücut sınırlama
spinePos = new Vector3(0, Mathf.Sin((headAngleY + offset) * Mathf.Deg2Rad), Mathf.Cos((headAngleY + offset) * Mathf.Deg2Rad));
spineTarget.transform.localPosition = spinePos;
headPos = new Vector3(yRotation * Mathf.Deg2Rad, Mathf.Sin(((headAngleY - 90) + offset) * Mathf.Deg2Rad), Mathf.Cos(((headAngleY - 90) + offset) * Mathf.Deg2Rad));
headTarget.transform.localPosition = headPos;
}
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.IsWriting)
{
stream.SendNext((Vector3)spineTarget.transform.localPosition);
stream.SendNext((Vector3)headTarget.transform.localPosition);
}
else
{
this.spineTarget.transform.localPosition = (Vector3)stream.ReceiveNext();
this.headTarget.transform.localPosition = (Vector3)stream.ReceiveNext();
}
}
But its not smooth on other players body. Its like its skiping frames. Not like normal walking & crouching animations.
Any help and idea would be great! Thank alot.