Behaviour Tree

Describes the concepts behind Behavior Trees in AI Tree.

Behavior Trees are created in a visual by adding and connecting a series of nodes which have some functionality attached to them to a Behavior Tree Graph. While a Behavior Tree executes logic, a separate asset called a Blackboard is used to store information (called Blackboard Keys) the Behavior Tree needs to know about in order to make informed decisions.

An example of a Behavior Tree where an AI character can patrol.

A typical workflow would be to create a Blackboard, add some Blackboard Keys, then create a Behavior Tree that uses the Blackboard asset (pictured below, a Blackboard is assigned to a Behavior Tree).

Assigned Blackboard

Behavior Trees in AI Tree execute their logic from left-to-right, and from top-to-bottom. The numerical order of operation can be viewed in the upper-right corner of nodes placed in the graph. In the image below, a sample of a branch placed in the left-most portion of a Behavior Tree graph has some nodes that instructs an AI to generate a random position and go to it.

Numbering of node execution.
Node isn't connected to one of the nodes.

To link a node, you must pull the connection from the top or bottom of the node (indicated by a circle) to the center of another node.

Link example

Connecting nodes in Behavior Trees only work by connecting an output to an input (you cannot connect from an input to an output).

We connect the nodes in this way:

Links example

To connect Behavior Tree to GameObject, we need to add a component to it Behavior Runner.

To do this, go to the inspector window of the necessary GameObject.

Clicks Add Component and searches Behavior Runner.

In the Behavior Runner field, connect our created Behavior Tree.

Last updated