Why are my animation transitions not always working?

I have several animations linked to my prefabs (which are enemy characters).
My animations are for “Running” and “Idle”.

For about half of my prefabs, even when the enemy stopped, the “Running” animation is still playing.
For the other half, it transitions to “Idle” as it’s supposed to.

Why is that happening? Why are some of the prefabs behaving erratically?
Can it be linked to the fact that all my physics (and the whole script) are in Update() instead of FixedUpdate()?

Thanks in advance

Yes that’s the one.

I use my Controller Script as a barebones interface. Nothing else resides inside this script other than the logic to make my Animations run and a few variables, which I expose for use by other scripts. I use these other scripts to Push values to these variables via GetComponent; so Force-feeding.

For example

var joystickInput : Vector2 = Vector2(0,0);

//In Update()
animator.SetFloat("walkFloat", joystickInput.y);
animator.SetFloat("turnFloat", joystickInput.x);

This is all the code that is required to animate my character between 5 states of forward motion, 2 states of backward motion and blending with turn animations.

In this script ‘joystick’ is not actually connected to a Joystick. It is just a Vector2 that I am free to inject from other scripts. This means I can input values from any script, any controller or even take over the character control in some kind of event.

The Animation script remains very lean this way and so will always be responsive, never feel sluggish and never miss Animation triggers.

Do this and you are halfway there. The rest is making sure your Transitions are correct, in Animator and be careful with Exit Time parameter.

Also, If you set a Bool in animator, make sure to Unset it!