State Trees
State Trees are UE’s newer hierarchical state machine system (introduced in UE 5.0), designed to replace Behavior Trees for many AI and gameplay use cases. BlueprintAI supports creating state trees, adding states, tasks, conditions, and transitions.
Creating a State Tree
Section titled “Creating a State Tree”Create a State Tree called ST_Enemy in /Game/AI
Adding states
Section titled “Adding states”Add a state called Patrol to ST_Enemy Add a state called Chase as a child of Patrol
States can be nested. Child states are entered when the parent is active and a transition condition is met.
Add a StateTreeTask called MoveToTarget to the Chase state Set the TargetActor property on MoveToTarget to read from the blackboard key Player
Tasks are the units of work executed while a state is active. You can use built-in task classes or custom UStateTreeTaskBase subclasses.
Conditions and transitions
Section titled “Conditions and transitions”Add a transition from Patrol to Chase when the condition CanSeePlayer is true Add a transition from Chase back to Patrol after 5 seconds if CanSeePlayer becomes false
Transitions fire when their conditions are satisfied. Conditions can be based on parameters, blackboard values, or custom condition nodes.
Parameters
Section titled “Parameters”Add a float parameter called AlertRadius to ST_Enemy with a default of 800
Parameters allow the same State Tree asset to behave differently depending on how it is configured on each actor that uses it.
import { Aside } from ‘@astrojs/starlight/components’;