Learn how to use NodeCanvas

Behaviour Trees


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

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

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

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.

Status Reference

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:

  • Resting, is a status which marks a node as “ready”, and it’s the status that nodes are reset to after each traversal when the tree resets. You should generally never return Status.Resting.
  • Success, means the node succeeded in its task.
  • Failure, means the node failed in its task.
  • Running, means the node is still running and the final status is yet to be determined.
  • Error, is a status that usually is returned when there is an execution error (like for example a required reference is not set). Status.Error is unhandled by the parent node (neither Success, nor Failure), which means that the parent node will simply continue its execution as if the node that returned Status.Error was not even there.
  • Optional, is similar to the above in that it is also unhandled and means that the parent node will continue its execution as if the node that returned Status.Optional was never there. The difference with Status.Error of course, is that Status.Optional is deliberately optional by choice.

Further Reading

If you want to further understand the logic behind Behaviour Trees, here are a few very interesting links:
Chris Simpson (
Debby Nirwan (
AI and Games (

Yes No Suggest edit
19 of 19 users found this section helpful
Suggest Edit