Search Unity

Third Party Photon PUN 2 and Animation Rigging

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

  1. Atix07

    Atix07

    Joined:
    Jul 27, 2013
    Posts:
    182
    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:
    182
    I cant seem to find documentation but try reading the youtube videos comments. You just have to apply photon transform view inside the viewobject.
     
  4. siddhiraj

    siddhiraj

    Joined:
    Aug 29, 2020
    Posts:
    5
    Can Anyone tell How to call Animation Rigging on network. Because I am new And I don't know how to do this.
     
  5. siddhiraj

    siddhiraj

    Joined:
    Aug 29, 2020
    Posts:
    5
    I got it add photon transform view to child of any animation rigged component object and add photon view and photon transform view to source object of that rigged component. It will work.
     
    art092 likes this.
  6. Neon_Apollo

    Neon_Apollo

    Joined:
    Dec 8, 2017
    Posts:
    13
    Hello, did you ever get this issue solved? I am having the exact same issue now, thanks!
     
  7. yunggod710

    yunggod710

    Joined:
    Jun 30, 2021
    Posts:
    1
    no need for extra stream syncing code stuff, just have transform view on all rigged objects and source objects, with a photon view also on the source obj (ie. camera has trans view and photon view, spine just has trans view
    )