Getting Started¶
Installation¶
Logic Driver installs normally through the Epic Games Marketplace. For detailed instructions please see the Installation Guide.
Videos¶
Tutorial Setup¶
Perform initial actor and material setup for Logic Driver tutorials.
Hello World Tutorial¶
Get started with state machines using Logic Driver.
Designing State Machines¶
Creation¶
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.
Context¶
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.
Similarities to Unreal Animation State Machines
Think of Get Context
as being similar to Try Get Pawn Owner
of Animation Blueprints.
States¶
When designing state logic you execute blueprint nodes like you would in a standard blueprint. You can also call Get Context
here or other helper nodes.
You can add a state by dragging a connection or right clicking in the graph. Double click on the state to enter its local graph
and place regular blueprint nodes.
Transitions¶
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 state means there is logic in the state and it can be taken to another state. A gray state means either the state can't be reached or it contains no logic. A red state means the state is an end state and will never transition to another state.
A grayed out transition means the transition is always false and will never be taken by default. A white transition means either transition is always true or has an expression wired to it.
Several helper nodes are also available here.
Using State Machines¶
Instantiate¶
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 you don't want your component to replicate, disable Component Replicates
.
If you uncheck Initialize on Begin Play
, then Initialize
must be called on the component manually before use.
Another option is adding a variable in a blueprint of your choice as an SMInstance (State Machine Instance) type. Then call Create State Machine Instance and manually pass in a context during run-time.
Memory Management
Remember to assign your instance to a member variable! If you just create the instance and start it, then it may be garbage collected by Unreal.
Initialize¶
State machine components and Create State Machine Instance will automatically initialize the state machine by default. If you disable this functionality then you must call Initialize
manually before use.
Start¶
If you are using a component and left Start on Begin Play
checked, then the component will automatically start On Begin Play
. Otherwise if you unchecked it, or are using a UObject, call Start
when you want it to begin processing.
When a state machine starts the active state will switch to the initial state and begin running state logic and checking transitions.
Stop¶
State machines can be configured to stop automatically on an end state. Under a state machine blueprint's Class Defaults
, set Stop on End State
to true.
You can also call Stop
manually.
Shutdown¶
When you are completely finished with the state machine you can optionally call Shutdown
which will both stop the state machine and free internal resources. The state machine will need to be initialized again in this case. Calling this generally isn't necessary.
Visual Debugging¶
When running a play in editor session, select the debug object from the debug filter to display the active states. You may also break point on most blueprint execution nodes like when using normal blueprints.