state_tree
Author StateTree assets: evaluators, tasks, conditions, transitions.
What it's for
StateTree is Unreal's hierarchical state machine for AI and gameplay logic. This namespace lets your
assistant author those assets directly: attach native task, evaluator, and condition nodes to states,
wire up transitions, and bind one node's property to another. Every node type is addressed by its
UScriptStruct name or path, so you describe the behavior you want and the assistant drops
in the right FStateTreeTaskBase, FStateTreeEvaluatorBase, or
FStateTreeConditionBase child.
Reach for it when you are building or editing StateTree logic and want the structure filled in from a description instead of clicking through the StateTree editor: adding a task to a state, gating a state's entry with a condition, or setting what triggers a transition (a tick, a gameplay event, or a completed child state).
This is a sibling to the behavior_tree namespace. Use state_tree when your
project drives its AI or gameplay through StateTree assets, and behavior_tree when the logic
lives in classic Behavior Tree assets instead.
Examples
Add a task to a state
Attach a native task node to an existing state so it runs while that state is active.
You: In ST_Guard, make the Patrol state run a MoveTo task.
call("state_tree.add_task", {stateTreePath:"/Game/AI/ST_Guard",
stateName:"Patrol", taskClass:"StateTreeMoveToTask", save:true})
→ {ok:true, nodeId:"A1F3..."}
Done. Patrol now runs a MoveTo task.
Gate a state with an enter condition
Add a condition to a state's enter conditions so it is only selected when the condition passes.
You: Only let ST_Guard enter Chase when the alert tag is set.
call("state_tree.add_condition", {stateTreePath:"/Game/AI/ST_Guard",
stateName:"Chase", conditionClass:"StateTreeGameplayTagMatchCondition",
target:"enter", save:true})
→ {ok:true, nodeId:"7C2B..."}
Done. Chase now requires the alert condition to enter.
Trigger a transition on a gameplay event
Set an existing transition to fire on a specific event tag rather than every tick.
You: In ST_Guard, make Chase go back to Patrol when it hears the lost-target event.
call("state_tree.set_transition_trigger", {stateTreePath:"/Game/AI/ST_Guard",
fromState:"Chase", toState:"Patrol", trigger:"OnEvent",
gameplayEventTag:"AI.Event.LostTarget", save:true})
→ {ok:true}
Done. Chase transitions to Patrol on the LostTarget event.