A Behavior Tree is a hierarchical tree of Nodes that controls the flow of the AI character's behavior. When we execute a Node, the node can return three states: success, failure, or running (if the node's execution is spread over multiple frames, for instance, if it plays an animation). When the BT executor runs a tree, it starts from the root and starts executing every node in order, according to rules written in the nodes themselves.
A Node can be of three types:
- A leaf (a node without children)
- A decorator (a node with a single child)
- A composite node (a node with multiple children)
In general, leaves represent the Action that the characters can do or know (that is why they are commonly called an Action or Task); they may be actions such as GoToTarget, OpenDoor, Jump, or TakeCover, but also things like IsObjectNear? or IsHealthLow...