User Guide
Last updated
Last updated
This section illustrates how to create the various Behavior Tree assets within Unity.
Behavior Trees are essentially the Is processor and can make decisions and execute various branches based on the outcome of those decisions. Now an example of creating a simple bot will be shown:
Behavior Trees are essentially the AI's processor and can make decisions and execute various branches based on the outcome of those decisions.
Click on the Assets tab, then select Create/Renowned Games/Behavior Tree
Also you can right-click in the Project Window, then select Create/Renowned Games/Behavior Tree
The new Behavior Tree asset will be added to the Project Window which you can rename to your desired name.
To create Random Position node, we need to go to the desired Behavior tree and right-click the context menu.
Click on Create Node/Tasks/NavMesh/Random Position
To save the position value we need to create Blackboard.
Click on the Assets tab, then select Create/Renowned Games/Blackboard
Also you can right-click in the Project Window, then select Create/Renowned Games/Blackboard
The new Blackboard asset will be added to the Project Window which you can rename to your desired name.
To connect Blackboard to the Behavior Tree, click on the Behavior Tree we need and drag the desired Blackboard into the Behavior Tree inspector window where the Blackboard field will be.
You can also add it by clicking on the field with blackboard and select it from all the blackboards in the project.
In the Blackboard, we create a Key with the vector type and call it position.
To create a Key, click on the New Key tab.
In the window that opens, select the Key type.
An example of how it should turn out:
In the Random Position node inspector window, specify your new Key.
So that our character can approach the generated position, we will create Move To node.
To create Move To node, we need to go to the desired Behavior tree and right-click the context menu.
Click on Create Node/Tasks/NavMesh/Move To
In the Move To node inspector window, specify position Key.
To create a small delay, we will create Wait node.
To create Wait, we need to go to the desired Behavior tree and right-click the context menu.
Click on Create Node/Tasks/Common/Wait
As in Move To Task, we add the position Key
In field Wait time specify 3 seconds.
If you don't want to create a Key in the Blackboard, then you can click on the flag next to the field and enter your fixed value.
To link our years we need to add Sequencer. Executes child nodes alternately.
To create Sequencer, we need to go to the desired Behavior tree and right-click the context menu.
Click on Create Node/Tasks/Composites/Sequencer
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 remaining nodes in the same way:
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.