Animator bug: trigger does not disable automatically [Unity 5.6.0f2 (64-bit)]

I need to play the animation once and I decided to use the triggers. You know that this works not as conceived?

I’m forced to use the function ResetTrigger

if (stateInfo.IsName(FightSystem.FighterHName))
                animator.ResetTrigger(FightSystem.FighterHName);

Otherwise, the stage is played 2 times.
What could be the problem? In my animation? Am I doing something wrong? Or this version of unity has such a feature?

I hope I can be helped here, I do not want to program it all by hand.

Are you certain you’re not setting the trigger multiple times?

If no trigger was resetting properly, I’d imagine we’d have a lot more people screaming at us at the moment.
If you can’t figure it out, file a bug

Yes, I am sure. In fact, the network has many similar questions. I think this is because of the transaction settings, but it is currently the default.

Please file a bug, we’ll check it out

Most likely I came across the problem described here. Just in case, I’ll throw off a bug report.

Ultroman’s answer is not 100% exact. The problem does not (always) occur when you trigger an animation that is currently being played. It does occur when you trigger an amination while a transition is still running.

Let’s say you have 2 animations: A and B and 2 triggers: tA and tB, animation A plays when tA gets triggered and animation B plays when tB gets triggered. If you trigger tA animation __A__will start playing, but if you trigger tB before animation A has finished, tA won’t be reset, it will remain true until animation A is played from begining to end. The same also happens if you trigger tA for a second time while animation A is still playing.

So, if for some reason you need to trigger tB and you are not sure if animation A has finished, you should use ResetTrigger, I didn’t understand why the guys at Unity decided to include this funtion until I stumbled upon this problem.

To prevent this unwanted behaviour you should do something like this:

  • animator.ResetTrigger(“tA”);
  • animator.SetTigger("tB);

1 Like

Triggers stay triggered until a transition that uses them is taken.
Whenever a transition using trigger tA is taken, the trigger gets reset when all layers have been evaluated (so that all layers have a chance to react to that trigger)

1 Like

Just experienced same problem with Version 2017.1.0f3 personal
I use setTrigger from Update loop C#. Sometimes (Not Always) Trigger does not reset after triggered animation is played.
I have with earlier releases done the exactly same thing with no problem. Also have some problem with debugging C sharp monobehaviours in vs 2017 from Unity 2017. I only have the Base Layer in my Animator controller

I had same problem
probably u are using Boolean instead of Trigger, u can see different shape next to it5434137--553638--upload_2020-2-2_10-33-27.png

1 Like

2019 has the same problem — I’ve put in breakpoints to assure I’m only setting the trigger once, but it never unsets on its own. The animation state that it triggers plays on an endless loop and the trigger stays set to true. (My player keeps getting hit endlessly, which would be funny if it weren’t frustrating)

the documentation says that triggers set themselves to false right away, which is what’s confusing us because clearly there are conditions where it doesn’t.

Every trigger that was used to take a transition is reset right after the state machine is evaluated.
If you have a reproducible case where it’s not, please send us a bug report, because I have just reviewed the code, and I don’t see any loopholes.

Even just a description of what kind of transition is triggering multiple times would be useful to help diagnose.

I have this issue but with mine, my character keeps triggering attack animation then locomation then back to attack! This only started happening when i put in a stopAttack trigger.

Here is a reproduction of the “Normal” trigger getting stuck.

Github project

Unity version 2020.2.0f1

In the first video it works as expected because I move the mouse slowly and OnPointerEnter/OnPointerExit events are fired in separate frames (first I move the pointer out of the box and then move it to the other one), thus _animator.SetTrigger() is called in separate frames as well.

https://www.youtube.com/watch?v=cbNvuoeEYeY

In the second video I move the mouse fast (from one box to another within one frame), so _animator.SetTrigger() is called twice in the same frame and because of that the “Normal” trigger gets stuck forever.

https://www.youtube.com/watch?v=hFTK5kgQhhM

I’ve just been struggling to work out why one of my triggers was being consumed, but the animation state wasn’t changing. After several hours of trying all sorts of different things, I think I figured it out.

I have two characters in the scene that have a default animation state. I use triggers to get them to their other animation state at different times. My trigger to get them back to their original state was called “Reset” in both animators. When setting this trigger on my second character, it was being consumed by the first character’s animator. I renamed the trigger and now I’m getting the behaviour I expected.

I don’t recall seeing this documented or mentioned (please correct me if I’m wrong). If I’m right, could the documentation be updated to make this nice and clear :slight_smile: Thanks.

For those who did the same mistake I did, double check if there’s not a transition in your looped clip. While doing the transitions between states it’s possible to create an inner transition from clip to same clips by mistake which you can see by a small while triangle hanging under the clip. If that’s the case just click on your clip and delete the inner transition and your trigger will reset automatically. Hope it helps someone

1 Like