Behavior Trees are commonly used in modern games and applications, to create dynamic behaviours by using small building blocks (nodes) that perform a certain task and control the flow of the behaviour for one or even more AI agent. Behaviour Trees can be thought as a simplified programming language, that though contains the most common down to the core of the operations needed such as conditions, actions, loops, sequencer and selections to name a few. NodeCanvas allows you to make such Behaviour Trees visualy, without the hassle or the need to understand the whole low level underline logic, but rather only the top high level one.
On each update (called a Tick) of the Behaviour Tree, it starts by executing the first node. That node will then perform a small task and return it’s status, either Succeeded, Failed, or not yet decided, meaning Running among some others (see later). Depending on the type of node that decision may stem either from itself or be determined based on one or more of it’s child nodes. As such there exist three disnstictive types of nodes a Behaviour Tree can have, those being:
Leaf nodes have no child nodes and they are the final destination of a Behaviour Tree tick, hense their name. Most commonly leaf nodes will either check a Condition; a state of the game, or perform an Action, altering the state of the game.
Composite nodes mostly exist to determine the flow of the Behaviour, controling which leaf nodes are going to be executed or in what order for example. As such, Composite nodes may have any number of child nodes, which will “ask” on how to proceed. The most basic of Composite nodes are the Sequencer, which executes all it’s child nodes in order until one Fails, and the Selector which executes all it’s child nodes until one Succeeds. The most reasonable way to think of those two, would be an AND and an OR in case you are familiar with boolean logic. If you are not, that’s still fine and you don’t have to be to use Behaviour Trees.
Decorator nodes are special in what each do, but generaly speaking they exists to somehow alter the functionality of their one and only child node that they can have. Common Decorators include Looping the child node for a number of times, Limiting access to a child node or Interrupting a child node’s execution to name a few. NodeCanvas comes with a handfull of Decorator nodes to allow faster and more flexible behaviour creation than usual.
As stated earlier, each node returns a Status. Here is a reference of the possible Status nodes can return/be at and what they are used for: