164 lines
7.7 KiB
ReStructuredText
164 lines
7.7 KiB
ReStructuredText
|
:github_url: hide
|
||
|
|
||
|
.. DO NOT EDIT THIS FILE!!!
|
||
|
.. Generated automatically from Godot engine sources.
|
||
|
.. Generator: https://github.com/godotengine/godot/tree/4.2/doc/tools/make_rst.py.
|
||
|
.. XML source: https://github.com/godotengine/godot/tree/4.2/modules/limboai/doc_classes/BehaviorTree.xml.
|
||
|
|
||
|
.. _class_BehaviorTree:
|
||
|
|
||
|
BehaviorTree
|
||
|
============
|
||
|
|
||
|
**Inherits:**
|
||
|
|
||
|
Contains Behavior Tree data.
|
||
|
|
||
|
.. rst-class:: classref-introduction-group
|
||
|
|
||
|
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 :ref:`BTSequence<class_BTSequence>`, :ref:`BTSelector<class_BTSelector>`, and :ref:`BTInvert<class_BTInvert>`. Leaf tasks represent specific actions to perform, like moving or attacking, or conditions that need to be checked. The :ref:`BTTask<class_BTTask>` class provides the foundation for various building blocks of the Behavior Trees. BT tasks can share data with the help of :ref:`Blackboard<class_Blackboard>`. See :ref:`BTTask.blackboard<class_BTTask_property_blackboard>` and :ref:`Blackboard<class_Blackboard>`.
|
||
|
|
||
|
\ **Note:** To create your own actions, extend the :ref:`BTAction<class_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 ``SUCCESS``, ``RUNNING``, or ``FAILURE``. These statuses determine how the tree progresses. They are defined in :ref:`Status<enum_BT_Status>`.
|
||
|
|
||
|
Behavior Trees handle conditional logic using condition tasks. These tasks check for specific conditions and return either ``SUCCESS`` or ``FAILURE`` based on the state of the agent or its environment (e.g., "IsLowOnHealth", "IsTargetInSight"). Conditions can be used together with :ref:`BTSequence<class_BTSequence>` and :ref:`BTSelector<class_BTSelector>` to craft your decision-making logic.
|
||
|
|
||
|
\ **Note**: To create your own conditions, extend the :ref:`BTCondition<class_BTCondition>` class.
|
||
|
|
||
|
Check out the :ref:`BTTask<class_BTTask>` class, which provides the foundation for various building blocks of Behavior Trees.
|
||
|
|
||
|
.. rst-class:: classref-reftable-group
|
||
|
|
||
|
Properties
|
||
|
----------
|
||
|
|
||
|
.. table::
|
||
|
:widths: auto
|
||
|
|
||
|
+--------+-------------------------------------------------------------+--------+
|
||
|
| String | :ref:`description<class_BehaviorTree_property_description>` | ``""`` |
|
||
|
+--------+-------------------------------------------------------------+--------+
|
||
|
|
||
|
.. rst-class:: classref-reftable-group
|
||
|
|
||
|
Methods
|
||
|
-------
|
||
|
|
||
|
.. table::
|
||
|
:widths: auto
|
||
|
|
||
|
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| :ref:`BehaviorTree<class_BehaviorTree>` | :ref:`clone<class_BehaviorTree_method_clone>` **(** **)** |const| |
|
||
|
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`copy_other<class_BehaviorTree_method_copy_other>` **(** :ref:`BehaviorTree<class_BehaviorTree>` p_other **)** |
|
||
|
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| :ref:`BTTask<class_BTTask>` | :ref:`get_root_task<class_BehaviorTree_method_get_root_task>` **(** **)** |const| |
|
||
|
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| :ref:`BTTask<class_BTTask>` | :ref:`instantiate<class_BehaviorTree_method_instantiate>` **(** Node p_agent, :ref:`Blackboard<class_Blackboard>` p_blackboard **)** |const| |
|
||
|
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`set_root_task<class_BehaviorTree_method_set_root_task>` **(** :ref:`BTTask<class_BTTask>` p_value **)** |
|
||
|
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
|
||
|
.. rst-class:: classref-section-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. rst-class:: classref-descriptions-group
|
||
|
|
||
|
Property Descriptions
|
||
|
---------------------
|
||
|
|
||
|
.. _class_BehaviorTree_property_description:
|
||
|
|
||
|
.. rst-class:: classref-property
|
||
|
|
||
|
String **description** = ``""``
|
||
|
|
||
|
.. rst-class:: classref-property-setget
|
||
|
|
||
|
- void **set_description** **(** String value **)**
|
||
|
- String **get_description** **(** **)**
|
||
|
|
||
|
User-provided description of the BehaviorTree.
|
||
|
|
||
|
.. rst-class:: classref-section-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. rst-class:: classref-descriptions-group
|
||
|
|
||
|
Method Descriptions
|
||
|
-------------------
|
||
|
|
||
|
.. _class_BehaviorTree_method_clone:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
:ref:`BehaviorTree<class_BehaviorTree>` **clone** **(** **)** |const|
|
||
|
|
||
|
Makes a copy of the BehaviorTree resource.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_BehaviorTree_method_copy_other:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **copy_other** **(** :ref:`BehaviorTree<class_BehaviorTree>` p_other **)**
|
||
|
|
||
|
.. container:: contribute
|
||
|
|
||
|
There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_BehaviorTree_method_get_root_task:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
:ref:`BTTask<class_BTTask>` **get_root_task** **(** **)** |const|
|
||
|
|
||
|
Returns the root task of the BehaviorTree resource.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_BehaviorTree_method_instantiate:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
:ref:`BTTask<class_BTTask>` **instantiate** **(** Node p_agent, :ref:`Blackboard<class_Blackboard>` p_blackboard **)** |const|
|
||
|
|
||
|
Instantiates the Behavior Tree and returns the root :ref:`BTTask<class_BTTask>`.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_BehaviorTree_method_set_root_task:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **set_root_task** **(** :ref:`BTTask<class_BTTask>` p_value **)**
|
||
|
|
||
|
Assigns a new root task to the **BehaviorTree** resource.
|
||
|
|
||
|
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
|
||
|
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
|
||
|
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
|
||
|
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
|
||
|
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
|
||
|
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
|
||
|
.. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
|