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:

94991-states.png

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:

  • State1 Exit
  • State 2 Enter
  • Transition Start
  • Transition End
  • State 2 Fully Blended.

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?

Hey I have the same problem. Thanks for printing out the order I will need to verify it too. Did you solve the issue.

This is a bit old, but I’ve done some experimentation and found this out:

Yes, normally the order is indeed:

  • State 1 Exit
  • State 2 Enter
  • Transition Start
  • Transition End
  • State 2 Fully Blended

Basic 2-step process

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:

  • Step 1: Unreal jumps to state 2 Which triggers State 1 Exit, State 2 Enter, and Transition Start Events immediately
  • Unreal waits for the transition blending to finish (Configured by whatever you set for Blend Settings Duration on the transition, default is 0.1s)
  • Step 2: Unreal Triggers Transition End and State 2 Fully Blended after the blended transition has finished.

Interrupts

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:

  • State 1 Exit
  • State 2 Enter
  • Transition Start
  • Transition Interrupt
  • State 2 Exit
  • State 3 Enter

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.

3 Likes