Finite State Machine
With version 1.1.0 Logic comes with state machine nodes which lets you easily create finite state machines. State machine nodes differ from conventional logic nodes as they can listen to OnEnter, OnUpdate and OnExit calls by the state machine controller.
Create a state machine
First we need to create a state machine controller node. This node runs the actual state. Right click on the node canvas and select: StateMachine / FSM Controller
We can now add some state outputs in the node inspector. (for example Wait, Success, Fail)
Add state actions
To perform state actions we need to connect the output of a FSM Controller with an Actions node first. Then we can define as many action outputs as we like.
A state machine action node differs from conventional Logic nodes as they have three state machine states: OnEnter, OnUpdate and OnExit. Here's an example code of an "empty" state machine action node:
Run conventional nodes
State machine nodes can be used along with the conventional logic nodes. To run conventional nodes you can use the action split node. As the name implies - the action split node splits the output of an actions node (OnEnter, OnUpdate, OnExit) and allows you to connect conventional nodes to each output.
OnEnter: Called once when entering the state.
OnUpdate: Called on every tick.
OnExit: Called when exiting the state.
Last updated