Skip to content

Nodes

There are 4 types of nodes in Behavior Trees plus a special node called Entry, which is a single node that can't be deleted and marks the root of the execution.

Tasks

A Task node is in charge of executing a specific set of Instructions when it runs.

It also contains a Conditions list, which is executed every time the graph is evaluated. If their value is not successful and the Instructions list are running it will return a Failure.

While the Instructions are running, the Task node returns Running and upon finishing them it returns Success.

Task node of a Behavior Tree

A simple Task

For example if a Task node is a direct child of the Entry node and it waits 1 second before finishing, running the graph will put the whole graph under the Running state and change to Success after one second.

Task node of a Behavior Tree

Composites

Composite nodes allow to branch and determine the order in which its child nodes are executed. There are multiple types of composites, which can be chosen selecting the Composite node and clicking on the field in the Inspector.

Composite node of a Behavior Tree

Selector

The Selector composite executes the left-most child first. If the conditions return a Success the composite node also returns Success.

However if the child returns Failure it attempts to execute the next child node.

Composite Selector type node of a Behavior Tree

If all nodes return Failure the composite also returns Failure.

Selector as an OR

The Selector composite type can be seen as an OR operator with their children.

Sequence

The Sequence composite executes the left-most child first and follows to the next if the execution of the previous one is Success.

If the execution of a child node returns Failure the composite node will also return a Failure.

Composite Sequence type node of a Behavior Tree

If all nodes return Success the composite also returns Success.

Sequence as an AND

The Sequence composite type can be seen as an AND operator with their children.

Parallel

The Parallel composite, as its name implies, executes all of its children at the same time and it can configure when the composite should be considered as Success by choosing the option from the field that appears in the Inspector.

Composite Parallel type node of a Behavior Tree

All Successful

For example selecting All Successful will make the composite node return Success if and only if all of its children have finished with a Success result. Otherwise it will return Failure.

Random Sequence

The Random Sequence composite works exactly the same way as the Sequence composite, except that the order in which its children are evaluated is chosen at random right before the graph is evaluated.

Random Selector

The Random Selector composite works exactly the same way as the Selector composite, except that the order in which its children are evaluated is chosen at random right before the graph is evaluated.

Decorators

Decorator nodes don't do anything but can transform the results of its child node. For example, the Invert node returns Success or Failure depending on the value of its child node.

Decorators node of a Behavior Tree

There are also multiple Decorator types of nodes

Fail

Returns Failure regardless of the result of its child.

Success

Returns Success regardless of the result of its child.

Running

Returns Running regardless of the result of its child.

Invert

Returns Success if its child node is Failure.

Returns Failure if its child node is Success.

Returns Running otherwise.

Repeat

Returns Running as long as the amount of times that its child has ran is below a specific number.

In other words, allows to execute its child a certain amount of times before returning its last result.

While Fail

Returns Running as long as its child is either Running or Failure.

Returns Failure otherwise.

While Success

Returns Running as long as its child is either Running or Success.

Returns Failure otherwise.

Sub Graph

A Sub Graph node allows to execute other Behavior Trees or even other types of AI systems, such as State Machines.

Sub Graph node of a Behavior Tree

This type of node behaves exactly the same as the Task node, except that instead of executing a collection of Instructions it executes another AI graph.