Cancel a trigger?

I noticed that when I use an animator’s “setTrigger” function in my code, that trigger remains in the animation controller until it is acted upon. So my character could be off doing all kinds of whatever animations that don’t react to the trigger, but once he gets back to the stuff that does it gets triggered and the animation is performed.

While I can imagine there are some situations where this is helpful, it has mostly been a hindrance to me. When I call a trigger, I really need it to be called right then, and if the current state doesn’t have anything that reacts to that trigger, then I want nothing to happen.

So is there a way I can cancel a trigger?
Or is there another method I can use to “trigger” changing a state that isn’t retained in memory? (I often can’t just play a state directly because I’m triggering things that could be called from multiple states.)

ResetTrigger will cancel it.

CrossFade(“State Name”, fadeDuration) will cause a transition without needing to actually set up one on the Animator Controller.

You might also be interested in Animancer (link in my signature) which lets you skip Animator Controllers entirely and just control everything in scripts.

I could just use “play state” for that; the idea of using a trigger is that it works from multiple states. Like if my character is in the air or on the ground I will need a different attack animation, but I can just send a trigger for “attack” without having to check if we play the grounded attack or airborne attack.

Thanks for the info about ResetTrigger.

But you still have to check if you’re grounded for other stuff anyway, so using that to determine which attack to use should not be a problem.