learn me a state tree!!

v: Unreal Engine 5.6 / revision 1

State Trees / Machines / Finite\

These are typically a framework or routine labeled as FSM, which boils down to either

actor.state = "idle"
or .changeState("walk")
and the like

Which can be as simple as enum values or complex as each state having an "entering" "exiting" set of routines. With each state in code being a boilerplate of functions like a programmatic interface

When such a concept is dropped into a GUI, each and every need and option has to take up space of pixels and location leading to a Complex System

So getting over the steps to get the system to output anything is typically the hardest task to accomplish with it being the first makes it exhausting to learn. Hang in there


Good places to learn properly

ThreeWays - Unreal Engine 5
UE5 || State Tree Blueprint Tasks Explained - Part 1
UE5 || State Tree Blueprint Tasks Explained - Part 2

Unreal Engine's Docs
Docs of sort


This tutorial is simply the BASICS of making a thing happen in a typical setting. This example is coupeled to the Actor instead of a more proper reusable component.

Some things are skipped as you need to know how to launch the app and make a blueprint and navigate around it.

This demo simulates an Actor in a seeking state, reaches a conditional and returns to an idle state.

The steps show the state tree print from an Actor, then produce a task basic walk transform in base state, then a conditional to finish the state and transition to a different task state.

If somethings not showing up, be sure to compile and save

Begin


Create an Actor, give it a mesh or whatnot, just for something to display.

Create a StateTree. Select the StateTree Component. The others AI and AISchema are for another tutorial.

skjfd skjfd

In the Blueprint Class of the actor add a Component "StateTree"

skjfd

In the Details: AI you should be able to select the StateTree

skjfd
skjfd

Compile

skjfd

Within the the StateTree you have the option to change the "Context Actor Class" to the blueprint its self further coupled it, but we don't need to for this example, so leave it as it is.

skjfd

Select the "Root" state, then press the "New Task" button and select "StateTree Task Blueprint Base". Save to whereever

skjfd
skjfd

Compile skjfd

Two steps: select the "Root"
1: Find the Details: Tasks area and press the plus circle.
2: Select the newly created task

skjfd

Compile

skjfd

Open the task, in the Functions override the tick event

skjfd

Build a simple print to test if stuff is working. Compile skjfd

Compile

skjfd

Run game

skjfd

Create a variable for the Actor reference of type Object Ref

skjfd

Be sure to enable the visible option

skjfd

Compile

skjfd

Back in the State Tree in the Detail: Task you should see the blue pill binding icon, select the actor skjfd

Compile

skjfd

Back in the Task, add something to further test the first state, here we have the most basic of walk. Use the Actor variable from earlier for target as "self" will not work here

skjfd

Compile, run game

skjfd

Part 2

Add a new state with "Add State" button

skjfd

To get the state to be outside of the Root you have to drag it around in the UI

skjfd

Select the new state. Make a new Task like before

skjfd

Add a print to ready a test

skjfd

In the first states Task, note to self, Finish Task node allows exiting the state

skjfd

Add a condition of any sort to trigger the Finish task node. Here we just wait then flip the actor

skjfd

In The state tree, with the new state selected, add the task

skjfd

Select the Root State then in the TransitionTo drop down select "idle" or whatever you named the other state

skjfd

Compile, run

skjfd skjfd

yay