-
Notifications
You must be signed in to change notification settings - Fork 8
Getting Started
To create a new state machine right click on the content browser, choose Blueprints, then State Machine. Open the asset and begin designing your state machine.
The Get Context node allows you to retrieve the context this state machine is running for. This is what gets passed into the state machine when it starts. Think of this as being similar to TryGetPawnOwner of animation state machines.
When designing state logic you execute normal blueprint nodes like you would in a regular blueprint. You can also call GetContext here or other helper nodes.
Transitions consist of a single boolean condition. A transition can only be taken to the next state if it is true.
Notice the node colors change when the transition is no longer false. A green node means there is logic in the node and it can be taken to another node. A gray node means either the node can't be reached or it contains no logic. A red node means the node is an end state and will never transition to another state.
When you are ready to use your state machine you can decide the best way to instantiate it. The easiest way is adding an ActorComponent to your actor. By default this will create the state machine instance on BeginPlay and pass in this Actor as the context. Actor components also support Network Replication out of the box.
If that doesn’t work for you, another option is adding a variable in a Blueprint of your choice as a StateMachineInstance type. Then call CreateStateMachineInstance and manually pass in a context during run-time.
Finally, call Start on the state machine instance when you want it to begin processing. This will set the state to the initial state and begin running state logic and checking transitions.