Search Unity

  1. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  2. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  3. Participate with students all over the world and build projects to teach people. Join now!
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

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

Discussion in 'Connected Games' started by wildchiild, Dec 8, 2018 at 2:01 PM.

  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