State Machine Enter/Exit State/Transition order
I'm confused by the order events seem to trigger in a state machine when changing states. Here is a simple example:
In the states' details, I've added custom blueprint events to the Enter/Left/Fully Blended Events. I've done the same thing for the transition's Start/End Transition Events. All those blueprint events get hooked up to printString functions to see which order they happen in. And that order turns out to be:
Why am I getting transition events after State 2's Enter? The documentation is very light on details concerning when/under what conditions exactly all those events trigger. Can we get any clarifications on this? And while I'm at it, when does the Interrupt Transition Event happen?
This is a bit old, but I've done some experimentation and found this out:
Yes, normally the order is indeed:
In terms of basic theory, it seems Unreal Animation graphs require that you always be in exactly one state at any given time. Therefore, even if you have a transition between states that lasts 1 full second (for nice smooth animation blending) it seems Unreal will actually instantly switch you from State 1 to State 2 as soon as the transition condition is met. It will then "remember" that it needs to perform the smooth transition blending from State 1 to State 2 which has a certain duration of time. Therefore, it seems the following is happening:
One catch I've found is that it's possible for the transition to be interrupted. If there is another condition edge in State 2 that takes the tree to a different state (e.g.: State 3) you have to be careful, because Unreal will jump to State 3 immediately as soon as that condition is true. This means your nice beautiful smooth transition from State 1 to State 2 will be aborted. In this situation only the events from Step 1 (above) will fire, none of the Step 2: events will fire. Instead of Step 2, you will get the "Transition Interrupt" event, and then all the events for entering State 3 will trigger as normal. It would look like:
The take-away lesson is be very careful about using the "Transition End" or "Fully Blended" events because there is a chance they will never be triggered if the State Machine switches to a different animation state before finishing the smooth transition blend.
answered Sep 23 '18 at 05:46 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here