In the Project window, navigate to where you want to create your state machine
Right-click and select Create โ Ninjutsu Games โ State Machine
Name your state machine (e.g., "EnemyAI" or "PlayerController")
Step 2: Open the Graph Editor
Double-click your new State Machine asset to open the Graph Editor.
You'll see a canvas with a Start Node and Exit Node already created. These nodes are automatically added to every new state machine and cannot be deleted.
Step 3: Add an Actions Node
Let's add some behavior:
Right-click on the canvas
Select Create Node โ Actions
Click on the new Actions node to select it
In the Inspector, click Add Action
Choose an action (e.g., Debug โ Log Message)
Configure the action (e.g., type "Hello from State Machine!")
Step 4: Connect the Nodes
Click on the output port (right side) of the Start node
Drag the connection to the input port (left side) of the Actions node
Release to create the connection
Step 5: Add a State Machine Runner
The Runner component executes your state machine on a GameObject:
Create or select a GameObject in your scene
Click Add Component
Search for State Machine Runner
Drag your State Machine asset to the State Machine field
You can also create a runner via Create โ Ninjutsu Games โ State Machine Runner
Step 6: Test It!
Press Play in Unity
Check the Console window โ you should see your log message!
๐ Congratulations! You've created your first state machine!
Next Steps
Now that you have the basics, explore these topics:
Add More Behavior
Trigger Nodes โ React to events like player input, collisions, or timers