Why doesn't an animation transition with an Exit Time of 0 immediately transition to the next state?
Using Unity 2018.3, I set up an
AnimatorController with two states:
Next. I wanted
Initial to transition to
Next immediately, so I tried setting an Exit Time of 0. However, this doesn't transition immediately:
As shown above,
Initial state still runs instead of transitioning immediately to the
Next state. (There is no
Motion attached to the
AnimationState, so perhaps it's using a default duration.)
Below are screenshots of my animation transition settings.
Strange behaviour with small non-zero ExitTime
I also tried using an Exit Time of 0.01 (i.e. transition after 1% of the animation has played), and it transitions almost immediately as I expect most of the time. However, occasionally it will still play the
In this case, even though it transitions to
Next immediately most of the time, it still occasionally waits for the
Initial state to complete. (It happens much less frequently than the image above suggests, but the issue becomes more frequent if I set the ExitTime even lower, e.g. 0.003).
From searching online, the recommended solution for immediate animation transitions seems to be to turn off Exit Time and use a condition (e.g. bool or trigger) to transition immediately instead.
(Edit: in my case, I've defined an animator bool parameter called
ImmediateTransition and set it to
true by default instead of using Exit Time 0.)
This seems to work, but I would like to better understand how Exit Time works and why it's not working the way I expect.