Node component

Root Node

It is the first active node to run the behavior tree.

You can connect with one child node.

Composite Node

It has one or more child nodes and controls which child nodes to execute.

How to control is described in CompositeBehaviour script.

You can also add Decorator scripts and Service scripts to be described later.

Built-in CompositeBehaviour

  • Selector
    Execute the child nodes in order from the left, terminate when the child node returns success , and return success.
    If all child nodes return failure, it returns failure.
    It is used when you want to find a successful node in order from the left and you do not want to run subsequent nodes.
  • Sequencer
    Execute the child nodes in order from the left, terminate when the child node returns failure , and return a failure.
    If all child nodes return success, success is returned.
    It is used when you want to execute all as long as the child node returns success.

For reference on the built-in CompositeBehaviour see here.

Arbor Reference : Built-in CompositeBehaviour

Action Node

The node that performs the action.

Write the ActionBehaviour script to see what action to take.

Also, we can add Decorator script and Service script here as well.

For reference on built-in ActionBehavior see here.

Arbor Reference : Built-in ActionBehaviour

For creating ActionBehaviour script, click here.

Scripting : ActionBehaviour

Decorator script

It is a script that can perform condition judgment, suspend or interrupt an executing node, repeat judgment at the end timing.

This script is used in addition to composite nodes and action nodes.

For reference of the built-in Decorator, please refer to here.

Arbor Reference : Built-in Decorator

For creating Decorator script, click here.

Scripting : Decorator

About condition judgment

When multiple Decorators are added to one node, the node is executed only when the result of logical operation for all condition judgments is true.

Logical Operation

The decorator's judgment result is logically operated to obtain the final result.

  • And
    Perform an AND operation with the result of the next higher Decorator.
    The logical operation result is true only when the result is true in both cases.
  • Or
    Perform an OR operation with the result of the next higher Decorator.
    If either is true, the logical operation result will be true.
  • Not
    NOT operation (invert) the result of Decorator.
    When enabled, the result of NOT operation and AND / OR operation are performed.

Logical operations are performed in order from the top.
According to “De Morgan's Law”, arrange the Decorators in order from the top so that the judgment result you want is obtained.

About AbortFlags

Abort or interrupt target is controlled by AbortFlags.

  • Self
    Performs condition determination while its node or its subordinate node is executing.
    If the result of condition judgment is false, abort and return failure to the parent node.
  • LowerPriority
    A node with a lower priority on the right side than its own node performs a condition determination during execution.
    If the result of the condition judgment is true, the currently executing node is suspended, and its own node becomes active.

It can be set by combining the above two flags.

Also, regardless of AbortFlags, condition judgment is performed once when its own node becomes active, and if it is false, it will be returned as a failure as it is.

Service script

Service scripts can be added to composite nodes and action nodes, scripts that can do something while the node is active.

Although it is not used in the example Behaviour Tree, For example, it is suitable for describing auxiliary processing such as adding a Service that stores the distance to the player in Parameter to the Selector node.

For creating Service script, click here.

Scripting : Service