limboai/doc_classes/BehaviorTree.xml

72 lines
4.6 KiB
XML

<?xml version="1.0" encoding="UTF-8" ?>
<class name="BehaviorTree" inherits="Resource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Contains Behavior Tree data.
</brief_description>
<description>
Behavior Trees are hierarchical structures used to model and control the behavior of agents in a game (e.g., characters, enemies, entities). They are designed to make it easier to create complex and highly modular behaviors for your games.
Behavior Trees are composed of tasks that represent specific actions or decision-making rules. Tasks can be broadly categorized into two main types: control tasks and leaf tasks. Control tasks determine the execution flow within the tree. They include [BTSequence], [BTSelector], and [BTInvert]. Leaf tasks represent specific actions to perform, like moving or attacking, or conditions that need to be checked. The [BTTask] class provides the foundation for various building blocks of the Behavior Trees. BT tasks can share data with the help of [Blackboard]. See [member BTTask.blackboard] and [Blackboard].
[b]Note:[/b] To create your own actions, extend the [BTAction] class.
The BehaviorTree is executed from the root task and follows the rules specified by the control tasks, all the way down to the leaf tasks, which represent the actual actions that the agent should perform or conditions that should be checked. Each task returns a status when it is executed. It can be [code]SUCCESS[/code], [code]RUNNING[/code], or [code]FAILURE[/code]. These statuses determine how the tree progresses. They are defined in [enum BT.Status].
Behavior Trees handle conditional logic using condition tasks. These tasks check for specific conditions and return either [code]SUCCESS[/code] or [code]FAILURE[/code] based on the state of the agent or its environment (e.g., "IsLowOnHealth", "IsTargetInSight"). Conditions can be used together with [BTSequence] and [BTSelector] to craft your decision-making logic.
[b]Note[/b]: To create your own conditions, extend the [BTCondition] class.
Check out the [BTTask] class, which provides the foundation for various building blocks of Behavior Trees.
</description>
<tutorials>
</tutorials>
<methods>
<method name="clone" qualifiers="const">
<return type="BehaviorTree" />
<description>
Makes a copy of the BehaviorTree resource.
</description>
</method>
<method name="copy_other">
<return type="void" />
<param index="0" name="other" type="BehaviorTree" />
<description>
Become a copy of another behavior tree.
</description>
</method>
<method name="get_root_task" qualifiers="const">
<return type="BTTask" />
<description>
Returns the root task of the BehaviorTree resource.
</description>
</method>
<method name="instantiate" qualifiers="const">
<return type="BTInstance" />
<param index="0" name="agent" type="Node" />
<param index="1" name="blackboard" type="Blackboard" />
<param index="2" name="instance_owner" type="Node" />
<param index="3" name="custom_scene_root" type="Node" default="null" />
<description>
Instantiates the behavior tree and returns [BTInstance]. [param instance_owner] should be the scene node that will own the behavior tree instance. This is typically a [BTPlayer], [BTState], or a custom player node that controls the behavior tree execution. Make sure to pass a [Blackboard] with values populated from [member blackboard_plan]. See also [method BlackboardPlan.populate_blackboard] &amp; [method BlackboardPlan.create_blackboard].
If [param custom_scene_root] is not [code]null[/code], it will be used as the scene root for the newly instantiated behavior tree; otherwise, the scene root will be set to [code]instance_owner.owner[/code]. Scene root is essential for [BBNode] instances to work properly.
</description>
</method>
<method name="set_root_task">
<return type="void" />
<param index="0" name="task" type="BTTask" />
<description>
Assigns a new root task to the [BehaviorTree] resource.
</description>
</method>
</methods>
<members>
<member name="blackboard_plan" type="BlackboardPlan" setter="set_blackboard_plan" getter="get_blackboard_plan">
Stores and manages variables that will be used in constructing new [Blackboard] instances.
</member>
<member name="description" type="String" setter="set_description" getter="get_description" default="&quot;&quot;">
User-provided description of the [BehaviorTree].
</member>
</members>
<signals>
<signal name="plan_changed">
<description>
Emitted when the [BlackboardPlan] changes.
</description>
</signal>
</signals>
</class>