Hello!
I am looking for what would be considered the “correct” or textbook method of instantly exiting and re-entering a state in a state machine.
Think of it as when a player is spamming a key to retrigger a taunt animation.
What I am looking for is not looping behavior. What I need is that when a condition turns true, the current state I am in “retriggers” or resets.
I have tried transitioning to an alias of the current state but from my initial tests, it doesn’t seem to work. (image 1)
I have also tried to quickly transition to an empty state when the key is pressed and then returning to the original state using an always True transition rule. This kinda works but also caused me several headaches on a past project. (image 2)
So I’m just looking for what would be the textbook way of “retriggering” a state like that, if any.
Thanks!
Hi, historically the state machines in anim blueprint haven’t been good at dealing with state re-entry in the way that you describe, where you want to retrigger the same state (or return to a state that is already active). What we’ve done on internal projects is similar to the approach that you mentioned - have an empty dummy state, or a duplicate state that we can go back and forth between.
However, this is changing in the 5.7 release as we’ve now added self-transitions and inertialized transitions that allow for proper state re-entry. In that release, you’ll see these new options when setting up your states (plus we’ve also changed the UI scheme):
[Image Removed]For cases where you want to be able to transition back into a state that is already active, you can now use the Allow Inertialization For Self Transition property to let you reactivate the state. You would use that in cases where you want to transition between states like A -> B -> A. The Self transition node is similar, but deals with the situation you mentioned, where a user spams a button to trigger re-transition to a state that’s already active. (Again, with this setup, you would use the Allow Inertialization for Self Transitions to allow the state to reactivate.) There’s also the Min Time Before Re-entry property that allows you to specify a threshold to gate the transition, if you want some form of cool down on it.
If you’re using the Inertialization option, you should also include an Inertialization or Dead Blending node downstream of your state machine.
If you’re interested in looking at the CL that introduced these changes it’s 43808897. It might be possible to backport the state re-entry changes specifically, although that CL also included many other state machine improvements so you’d need to unpick those.
That sounds amazing [mention removed] !!
Been struggling with this one for a long time!
Looking forward to be jumping on 5.7 to try this out!!
Please let us know if you have any feedback on the new functionality once you’ve tried it!