Behaviour 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 more AI agents. 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, sequencers and selections to name a few. NodeCanvas allows you to make such Behaviour Trees visually, without the hassle or the need to understand the whole low-level underlined 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 its status, either Success, Failure, 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 its child nodes. As such there exist three distinctive 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, hence 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, controlling 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” how to proceed. The most basic of Composite nodes are the Sequencer, which executes all its child nodes in order until one Fails, and the Selector which executes all its child nodes in order 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. NodeCanvas comes with all commonly found composite nodes in behaviour trees as well as more unique ones.
Decorator nodes are special in what each does, but generally speaking they exist to somehow alter or append to the functionality of their one and only child node that they can have. Common Decorators include Looping the child node 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 handful of Decorator nodes to allow faster and more flexible behaviour tree designs than usual.
As stated earlier, each node returns a Status. Here is a reference of the possible Status that nodes can return/be at and what they are used for:
© Paradox Notion 2014-2024. All rights reserved.