Getting Animator states to transition properly

Hey Guys,

I’ve just started messing around with the Animator and I’m having a small runtime error with the state machine in the Animator.

I’ve got this bit of code below that checks for a mouse button click and sets the condition of the bool to true which should transition the state machine to the next state which plays the slashing animation. Once I let go of the button it sets the bool back to false returning it back to the default state.

        if (Input.GetKeyDown(KeyCode.Mouse0) && Sword.transform.IsChildOf(WeaponHold.transform))
        {
            otherAnimator.SetBool("Clicking", true);
            Debug.Log("Slashing");
        }

        if (Input.GetKeyUp(KeyCode.Mouse0) && Sword.transform.IsChildOf(WeaponHold.transform))
        {
            otherAnimator.SetBool("Clicking", false);
            Debug.Log("Slash Reset");
        }

The debug logs show up on the console.
This is my state machine currently

I should clarify that the “StillSword” state works and the “Sword” state works.

What I’m wondering is when I press the mouse button why it won’t play “Slash” animation. I’m pretty sure its something simple that I’m just not aware of about in terms of the Animator.

Thanks

because you have Has Exit time checked, and probably the default value for exit time which mean that the transition can only occur when clip still sword is past this time threshold.

To transition from stillsword to slash at any time simply uncheck has exit time

1 Like

Ah thanks man, I wasn’t aware of what exactly HasExitTime did but I guess it should have made sense. One thing I did have to switch was the bool logic to a Trigger on the animation.

yes a trigger and bool have different semantic.
a Trigger work mostly like bool parameter, but their values are reset to false when used in a Transition if the transition is triggered.