Search Unity

The animator is not Synced

Discussion in 'Multiplayer' started by ARares, Jul 15, 2017.

  1. ARares

    ARares

    Joined:
    Mar 18, 2016
    Posts:
    167
    In this code, the animator is synced just when i jump, for example, if i jump while i run, when i touch the ground, the animation is stuck on Running.:

    I am using Unity Standard Assets Characters.

    Code 1:
    Code (CSharp):
    1.     Animator animator;
    2.     NetworkAnimator networkAnimator;
    3.  
    4.     void Start()
    5.     {
    6.         animator = GetComponent<Animator>();
    7.         networkAnimator = GetComponent<NetworkAnimator>();
    8.  
    9.  
    10.         networkAnimator.SetParameterAutoSend(0, true);
    11.     }
    12.  
    13.     void Update()
    14.     {
    15.  
    16.         if (isLocalPlayer)
    17.         {
    18.             float horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
    19.             float vertical = CrossPlatformInputManager.GetAxis("Vertical");
    20.  
    21.             float animSpeed = Mathf.Abs(vertical);
    22.             float strafeSpeed = Mathf.Abs(horizontal);
    23.  
    24.             Animations(animSpeed, strafeSpeed);
    25.         }
    26.     }
    FPS Controller:


    Code (CSharp):
    1.         private void Update()
    2.         {
    3.             RotateView();
    4.             // the jump state needs to read here to make sure it is not missed
    5.             if (!m_Jump)
    6.             {
    7.                 m_Jump = CrossPlatformInputManager.GetButtonDown("Jump");
    8.                 animator.SetBool("IsJumping", m_Jump); //Animation
    9.             }
    10.  
    11.             if (m_Jump)
    12.             {
    13.                 animator.SetBool("IsGrounded", false); //Animation
    14.             }
    15.  
    16.             if (!m_PreviouslyGrounded && m_CharacterController.isGrounded)
    17.             {
    18.                 StartCoroutine(m_JumpBob.DoBobCycle());
    19.                 PlayLandingSound();
    20.                 animator.SetBool("IsGrounded", true); //Animation
    21.                 m_MoveDir.y = 0f;
    22.                 m_Jumping = false;
    23.             }
    24.  
    25.             if (!m_CharacterController.isGrounded && !m_Jumping && m_PreviouslyGrounded)
    26.             {
    27.                 m_MoveDir.y = 0f;
    28.             }
    29.  
    30.             if(!m_CharacterController.isGrounded)
    31.             {
    32.                 animator.SetBool("IsGrounded", false); //Animation
    33.             }
    34.  
    35.             m_PreviouslyGrounded = m_CharacterController.isGrounded;
    36.         }
    Image:
    Capture.JPG


    P.S. this problem is after i made the animations on Jump, before the jump animations, this worked fine.