Hi all,
is there a reliable way to determine if a transition from one animation to the next one has finished?
My problem is as follows:
I got an idle animation, running, stopping and aiming (raising a crossbow).
I also got internal states for the player (an enum with isIdle, isRunning etc.)
When I start running the running animation is played, the internal state of the player is set to isRunning.
When I stop running, the stopping animation is played, the internal state is isStopping and at the end of the animation the animator automaticaly plays the idle animation again and I fire an animation event so that my internal state can also switch to isIdle again. This works fine.
When inIdle, I can press the mouse button to aim my crossbow at something, the animation gets played and internal state is isAiming. When I release the mouse button, there is a transition back to idle. But my internal state is immediately set in code to isIdle. This is a problem because the player can then start running. This is not seen in the animation since the animator is still in transition to the idle animation. But the internal states start to differ and since there is no running animation there will be no stopping animation and no animation event to help getting from isStopping to isIdle again.
What I would need is an event telling me the transition from aiming to idle is ready, the animator can now receive all the input for the idle state. I tried to use GetAnimatorTransitionInfo.normalizedTime to check when it reaches 1 but this is not reliable, I guess when it is 1, the info gets deleted hence there is no transition anymore. Anyway I can’t check for that.
Another option would be to create a stoppingAiming animation like with the running and let that fire an event and transition very fast without blending to idle animation again. But that sounds like a lot of unnecessary work.
How do you keep your animator states and internal player states in synch?
Thanks in advance, this is driving me crazy!