Search Unity

  1. We have added dedicated sub-forums for UNet, the experimental MLAPI and Unity Transport Package. Please use the new forums to discuss related topics.
    Dismiss Notice
  2. How can our website serve you better? Give us your feedback. Take our survey and let us know.
    Dismiss Notice

Help Wanted Photon PUN 2 and Animation Rigging

Discussion in 'Multiplayer' started by Atix07, Nov 7, 2020.

  1. Atix07

    Atix07

    Joined:
    Jul 27, 2013
    Posts:
    173
    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:
    Code (csharp):
    1. void LateUpdate() //animation rigging
    2.     {
    3.         if (!PV.IsMine)
    4.             return;
    5.         headAngleY += mouseY;
    6.  
    7.         headAngleY = Mathf.Clamp(headAngleY, 0, 140); //Vücut sınırlama
    8.  
    9.         spinePos = new Vector3(0, Mathf.Sin((headAngleY + offset) * Mathf.Deg2Rad), Mathf.Cos((headAngleY + offset) * Mathf.Deg2Rad));
    10.         spineTarget.transform.localPosition = spinePos;
    11.  
    12.         headPos = new Vector3(yRotation * Mathf.Deg2Rad, Mathf.Sin(((headAngleY - 90) + offset) * Mathf.Deg2Rad), Mathf.Cos(((headAngleY - 90) + offset) * Mathf.Deg2Rad));
    13.         headTarget.transform.localPosition = headPos;
    14.     }
    15.     public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    16.     {
    17.         if (stream.IsWriting)
    18.         {
    19.             stream.SendNext((Vector3)spineTarget.transform.localPosition);
    20.             stream.SendNext((Vector3)headTarget.transform.localPosition);
    21.         }
    22.         else
    23.         {
    24.             this.spineTarget.transform.localPosition = (Vector3)stream.ReceiveNext();
    25.             this.headTarget.transform.localPosition = (Vector3)stream.ReceiveNext();
    26.         }
    27.     }
    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.
     
    Last edited: Nov 7, 2020
  2. Cupcake_Actual

    Cupcake_Actual

    Joined:
    Aug 19, 2017
    Posts:
    2
    I don't understand how you go animation rigging working at all with PUN. I havn't had much luck, but i just started trying this week.

    Is there any good documentation for it?
     
  3. Atix07

    Atix07

    Joined:
    Jul 27, 2013
    Posts:
    173
    I cant seem to find documentation but try reading the youtube videos comments. You just have to apply photon transform view inside the viewobject.
     
unityunity