I’m trying to work out if my understanding of behaviour trees, services and decorators is correct. There is precious little documentation on these that I have found. I’ll lay my understanding of how these work here and I’d love it if someone could correct me on any mistakes.
A behaviour tree is a tree that consists of the following nodes, it goes through the nodes left to right:
Selector: this node executes its children, if a child fails it moves onto the next one. If a child succeeds it returns the node as a success. Only if all children fail does it returns the node as a failure.
Sequencer: This node executes its children , if a child succeeds it moves onto the next child. if all children succeed it returns the node as a success. if any child fails it returns a failure.
Simple Parallel: This node executes its main task, when the main task finishes it returns success or failure depending on the main task success. It also executes its background nodes at the same time. I am unsure if the background nodes are executed left to right or simultaneously.
The leaf nodes are Behaviour Tree Tasks:
A behaviour tree task has an event Receive execute and will continue running until this event returns success or failure.
There also exist Decorators and Services.
Decorator: This sits on a node or leaf, it has access to several events:
- Begin Execute, Finish Execute, and Tick: can be used to perform actions that are agnostic to the node / leaf it is attached to.
- Condition Check: This executes when the node is being checked if it is possible. You can return whether to allow execution or not. This facet seems vital to controlling flow across the tree.
Service: These sit under nodes (not leaves) and execute every ~n seconds. I’m not fully sure of the purpose of these but it seems to be to update the blackboard to changing aspects in the world. Such as if the player is now visible etc.
Is my understanding of behaviour trees correct? Are there any gaps or details I am missing? Or is there full documentation of this that I’ve been unable to find.