1
\$\begingroup\$

I've a 'classic' humanoid player with an animation controller and some animations.

This is the code i'm managing state changin

        float h = CrossPlatformInputManager.GetAxis ("Horizontal");
        if (h < 0) {
            m_Animator.SetTrigger ("LeftWalking");
        }
        else if (h > 0) {
            m_Animator.SetTrigger ("RightWalking");
        }
        else if (m_CharacterController.velocity.magnitude != 0) {
            m_Animator.SetTrigger ("Walking");
        }
        else if (m_Jumping) {
            m_Animator.SetTrigger ("Jump");
        }
        else {
            m_Animator.SetTrigger ("Idle");
            m_Animator.ResetTrigger ("Walking");
            m_Animator.ResetTrigger ("LeftWalking");
            m_Animator.ResetTrigger ("RightWalking");
            m_Animator.ResetTrigger ("Jump");
        }
    }

My problem is that after i stop to press my "forward" button (that make my player walking), the walking animation continue to play itself till the end.

This is my state machine enter image description here

This is options of Walking to Idle state

enter image description here

I'm pretty sure I've to "play" with HasExitTime and/or FixedDuration but i'm not sure...

\$\endgroup\$
3
\$\begingroup\$

Remove the HasExitTime checkbox to allow the transition to trigger at anytime.

See the documentation about HasExitTime

\$\endgroup\$
  • \$\begingroup\$ In your opinion is it also correct to manage state using Trigger variable instead Boolean ? \$\endgroup\$ – stighy Feb 15 '18 at 16:05
0
\$\begingroup\$

As Basile already said, uncheck HasExitTime. You should also uncheck the fixed duration box and set the transition duration to 0. Good luck:)

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.