Programmatic transitions

State A
State B1
State B2
State C

By assigning a function to a transition to state, you can determine the target state at run time.

The example above will alternately choose the top or bottom route based on a toggling variable.

In a more complicated setup such as a game or quiz, you could use something like this to branch at a particular point, for example character animation states, game bonuses, or the result of some other action, whilst staying inside the structure of the StateMachine.

Note that this example uses a mix of object configuration (to add the function) and shorthand notation (to make it easy).