Speed multiplier ignores exit time

Hi all,

I’m using a multiplier for my speed value to play an animation in reverse. If I disable the multiplier everything works as expected, however with the multiplier enabled (and it being set to -1), the state continues to repeat over and over. I have tried setting Exit Time to both 0 and 1, but nothing lets it leave the state.

However like I said, if I simply disable the multiplier checkbox, it transitions as expected.

Any help is greatly appreciated!

I’ve made a test project to show the issue:

https://www.dropbox.com/s/xmq4qkiydasqq8g/Animation%20Issue%20Example.zip?dl=1

So in the example, if you hold right click the stick should animate down, then once the animation is complete animate side to side. Once you let go of right click, the stick should animate up and then return to idle.

The issue is two fold:

  • The stick animation has to complete, you can’t let go half way through and it animate from where it was.
  • Secondly, the middle state (“Animate Out”) uses a multiplier on it to determine whether it should the animation should play forwards or backwards, and it seems like the animation never finishes when it goes backwards, so on returning to idle, it gets stuck in the middle state.

Thanks so much for your help!

Hi gumboots

Can you log a bug in Unity with this test project?

This is not something we are aware of.

We will investigate the issue.

Thx

Just logged a bug report.

I don’t suppose you have any tips for my other requirement?

https://forum.unity3d.com/threads/stop-animation-half-way-through-and-reverse.487009/#post-3175678

Trying to stop an animation half way through and reverse it, instead of needing to start from the start again on interrupt?

Reversing an animation clip with the speed multiplier on the state should work without restarting the animation from start.
I did the feature myself for Tank project in 5.0 to animate the Tank track, so if it not working anymore it broken.

But I agree a transition with an exit time on a state with a speed multiplier can be confusing, if the transition is already started and you start to rewind the clip, the transition time should continue to progress.

Without investigating the issue with your project it’s hard to tell you what you should expect.

If you think the behaviour is wrong or buggy you should log a bug with all the details and we will investigate.

Well to my thinking, if the exit time is 0, then it should leave at the beginning of the animation. Is that right? Therefore if I can reverse an animation, I’d probably also need to change the exit time at the same time, I’m not sure if that is possible? I can’t figure out how to target a specific state, outside of fetching the currently active state. But determining that in script is like writing a separate FSM to monitor Mecanim’s FSM, isn’t it?

unfortunatelly the answer is no
https://docs.unity3d.com/ScriptReference/Animations.AnimatorStateTransition-exitTime.html
You need at least one evaluation of your state before you can trigger an exitTime condition, meaning a transition with an exitTime of 0 will never be fired on the first frame.

Many people are confused with the exit time condition, many user think that if the current time is past the exit time the condition will be evaluated to true which is not the case.

So in your case why would you want to put an exit time condition if what you want is have a transition than can occur at any time?

You can’t change the exit time condition at runtime.

No need to write a separate FSM, you can use a StateMachineBehaviour which can be attached to this particular state.
https://docs.unity3d.com/ScriptReference/StateMachineBehaviour.html

So when the animation is playing forward, I want it to exit at 1, but when it’s playing backwards, I want it to exit at 0 (of the normalized animation time). Or when playing it reverse, does ‘1’ mean the start?

He’s setting the speed negative, so the time can reach frame 0 without being the first frame. When I looked at it in the other thread, it seemed like exit time transitions simply don’t work when the speed is negative. They act like they’re testing “current frame >= exit frame && previous evaluated frame < exit frame”, eg. crossing in the positive direction, without reversing the check if the speed is negative.

This is really awkward. no solutions?? 2018.3.0.f2

1 Like

Faced this problem in 2020.3.3f1. HasExitTime does not work if the animation speed is set to -1 at runtime. Is there a solution? Is the error still not resolved?

This problem also exists in 2021.2.12f1.

I have a state with an animation, which plays at a Speed of 0.3.
I have a single transition out of that state into a second state, with an ExitTime of 0.1, and a condition that is always true (I just created a new boolean parameter that’s set by nothing, and thus remains always true).
The transition has a fixed duration of 0.

Yet the transition only plays AFTER the first animation has fully played, although it should play at 10% given the exit time of 0.1. I tried changing the duration, enabling/disabling the fixed duration, but nothing seems to work…

Here are a few screenshots:

EDIT:
I believe I found the solution, of which I am not sure whether its indented behavior or not:
Apparently the exit time is not evaluated at all when the transition TO the state that fails to transition is still blending to that state. In other words, if you want to exit a state at 10%, but your transition to that state ends its blending at 30%, your exit time will be ignored and effectively treated as Exit Time = 1.