Getting Started¶
This walks through creating a tree, opening it in AI Editor, and running it on a GameObject. Install the package first; see Installation.
Create BehaviourTreeData¶
There are two common ways:
- In the Project window, use
Create/Aethiumian AI/Behaviour Tree. - Open
Window/Aethiumian AI/AI Editor, then clickCreate New Behaviour Treewhen no tree is selected.
When a new asset is created from AI Editor and the current Unity Selection is a GameObject, the editor tries to add or reuse an AI component on that object and assign the new tree when AI.Data is empty.
Open AI Editor¶
You can open it from:
- Unity menu:
Window/Aethiumian AI/AI Editor. - Select a
BehaviourTreeDataasset and clickOpen AI Editorat the top of its Inspector. - Select a GameObject with an
AIcomponent and clickOpen Editorin the AI component Inspector.
After opening the window, choose the target BehaviourTreeData in the top Behaviour Tree object field. Reopening the same tree focuses its existing AI Editor window; opening another tree creates or focuses that tree's own window.
Bind and run¶
- Add an
AIcomponent to the GameObject that should run the tree. - Assign the
BehaviourTreeDataasset toAI.Data. - If the tree asset sets
targetScript, make sure the same GameObject has that component;AI.OnValidate()tries to bind it toControlTarget. - Keep
awakeStartenabled when the tree should start automatically on scene entry; keepautoRestartenabled when the tree should loop after it ends. - During Play Mode, use the AI component context menu or Inspector controls to start, reload, pause, continue, or end execution.
Build the first tree¶
- Select or create a
BehaviourTreeDatain AI Editor. - If there is no root node, create a flow node as the head, such as
Sequence,Decision, orLoop. - Add child nodes to the head in the node editor.
- Add required variables in the variable table, then bind node fields through
VariableFieldorVariableReference. - Save the asset, enter Play Mode, and observe execution through the AI component or AI Runtime Inspector.