Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Unity 2018.3 is now released.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    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