How Behaviour Tree nodes work
mainA behaviour tree executes from a root node and traverses down through its children. Each node returns one of three states:
successfailurerunning
When a child returns running, the tree traversal typically stops for the current frame, and the state bubbles back up to the root. Parent nodes interpret these return states to decide the next course of action.
Nodes are categorized into three main types:
- Action Nodes: Leaf nodes with no children. They represent the agent's capabilities (e.g.,
MoveToPosition,Wait). - Composite Nodes: Control flow nodes that can have multiple children (e.g.,
Sequencer,Selector). - Decorator Nodes: Nodes with exactly one child used to modify or hide the child's return state (e.g.,
Inverter,Repeat).