BehaviourTree

class in RenownedGames.AITree / Inherits from ScriptableObject

The BehaviourTree class is responsible for defining, managing, and controlling the behavior trees used in AI logic.

Public Methods

Clone()

Description: Clones the entire behavior tree, including all nodes and settings.

Returns: BehaviourTree β€” A new cloned copy of the behavior tree.

Example:

BehaviourTree clonedTree = originalTree.Clone();

GetBlackboard()

Description: Shared Blackboard reference associated with this behaviour tree reference

Returns: Blackboard β€” The blackboard used by this behavior tree.

Example:

Blackboard blackboard = behaviourTree.GetBlackboard();

GetUpdateMode()

Description: Retrieves the current update mode for the behavior tree.

Returns: UpdateMode β€” The current update mode (e.g., Update, FixedUpdate, LateUpdate, Custom).

Example:


SetUpdateMode(UpdateMode mode)

Description: Sets the update mode for the behavior tree.

Parameters: UpdateMode mode β€” The desired update mode.

Example:


GetTickRate()

Description: Retrieves the tick rate, which defines how often the behavior tree updates.

Returns: int β€” The number of ticks per second.

Example:


SetTickRate(int count)

Description: Sets the tick rate for how often the behavior tree should update.

Parameters: int count β€” The number of ticks per second.

Example:


IsRunning()

Description: Checks whether the behavior tree is currently running.

Returns: bool β€” true if the tree is running, false otherwise.

Example:


GetRootNode()

Description: Retrieves the root node of the behavior tree.

Returns: Node β€” The root node of the behavior tree.

Example:


GetNodes()

Description: Returns the list of all nodes in the behavior tree.

Returns: List<Node> β€” The list of all nodes.

Example:


SetNodes(List<Node> value)

Description: Sets the list of nodes in the behavior tree.

Parameters: List<Node> value β€” The list of nodes to assign.

Example:


GetCurrentNode()

Description: Returns the currently executing node.

Returns: Node β€” The node currently being executed.

Example:


Static

TraversePath(Node node, Node searchingNode)

Description: Traverses the path from a specified node to a target node.

Parameters: Node node β€” The starting node. Node searchingNode β€” The target node to find.

Returns: LinkedList<Node> β€” The path of nodes leading to the target.

Example:


Traverse(Node node, Action<Node> visiter)

Description: Traverses all nodes from the target node with a visitor callback. Note: This method is obsolete; use Node.Traverse() instead.

Parameters: Node node β€” The starting node. Action<Node> visiter β€” The callback to apply to each node.

Example:


GetChildren(Node node)

Description: Returns all child nodes of a given node.

Parameters: Node node β€” The parent node.

Returns: List<Node> β€” The list of child nodes.

Example:


IterateChildren(Node node)

Description: Iterates through all child nodes of a given node.

Parameters: Node node β€” The parent node.

Returns: IEnumerable<Node> β€” An enumerable collection of child nodes.

Example:


IsSubNode(Node node, Node checkNode)

Description: Checks if a node is a sub-node of another node.

Parameters: Node node β€” The parent node. Node checkNode β€” The potential sub-node.

Returns: bool β€” true if checkNode is a sub-node of node, false otherwise.

Example:

Create(string name)

Description: Creates a new behavior tree asset in the project.

Parameters: string name β€” The name of the new behavior tree asset.

Example:


Protected Virtual Methods

Use the following methods only for overriding when inheritance, it is not recommended not to call these methods manually.

OnEnable()

Description: Called when the behavior tree is loaded.

Example:


Reset()

Description: Called when the user presses the Reset button in the Inspector, or when the component is first added.

Example:

Last updated