Behaviour Tree
Describes the concepts behind Behavior Trees in AI Tree.
Last updated
Describes the concepts behind Behavior Trees in AI Tree.
Last updated
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.
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).
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.
If you forgot to connect one of the nodes, it will show you this warning:
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.
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:
In order for the tree to work in game mode, you need to add a component to the GameObject, in which you specify the desired tree.
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.