Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Unity Multiplayer [Animator] Sync blend tree float variables with network animator

Discussion in 'Connected Games' started by wildchiild, Dec 8, 2018.

  1. wildchiild

    wildchiild

    Joined:
    Jul 2, 2017
    Posts:
    1
    Hello,
    I'm facing a problem with synching float transform.x, transform.z used in Animator blend tree to animate the player.

    Problem : the velocity variable is synched only once ( when move inputs pressed ), and it remains the same even if the actual value changes. Case of joystick use.

    I do print those values on each client side and they change correctly, but they doesn't sync on the other side.

    Basicaly i have this :
    Code (CSharp):
    1. void Update(){
    2.            
    3.             if (!isLocalPlayer)
    4.             {
    5.                 return;
    6.             }
    7.            
    8.            
    9.  inputHorizontal = joystick.Direction.x;
    10.             inputVertical = joystick.Direction.y;
    11. }
    12.  
    13. void FixedUpdate(){
    14.            
    15.             if (!isLocalPlayer)
    16.             {
    17.                 return;
    18.             }
    19. }
    20.  
    21. oid LateUpdate(){
    22.            
    23.             if (!isLocalPlayer)
    24.             {
    25.                 return;
    26.             }
    27.            
    28.             //Get local velocity of charcter.
    29.             float velocityXel = transform.InverseTransformDirection(rb.velocity).x;
    30.             float velocityZel = transform.InverseTransformDirection(rb.velocity).z;
    31.             //Update animator with movement values.          
    32.            
    33. // values are synched only once
    34.             animator.SetFloat("Velocity X", velocityXel / runSpeed);
    35.             animator.SetFloat("Velocity Z", velocityZel / runSpeed);
    36.            
    37. //tried those two lines ..
    38. //nwanimator.animator.SetFloat("Velocity X", velocityXel / runSpeed);
    39. //nwanimator.animator.SetFloat("Velocity Z", velocityZel / runSpeed);
    40.  
    41. }
    Keep an eye on Velocity Z.
    Joystick.Direction.z is constantly changing but not correctly sent.



    Thanks for help