2024-01-12 20:05:50 +00:00
:github_url: hide
.. DO NOT EDIT THIS FILE!!!
.. Generated automatically from Godot engine sources.
2024-07-20 15:25:24 +00:00
.. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
.. XML source: https://github.com/godotengine/godot/tree/master/modules/limboai/doc_classes/BTTask.xml.
2024-01-12 20:05:50 +00:00
.. _class_BTTask:
BTTask
======
**Inherits:** :ref: `BT<class_BT>`
**Inherited By:** :ref: `BTAction<class_BTAction>` , :ref: `BTComment<class_BTComment>` , :ref: `BTComposite<class_BTComposite>` , :ref: `BTCondition<class_BTCondition>` , :ref: `BTDecorator<class_BTDecorator>`
Base class for all :ref: `BehaviorTree<class_BehaviorTree>` tasks.
.. rst-class :: classref-introduction-group
Description
-----------
Base class for all :ref: `BehaviorTree<class_BehaviorTree>` tasks. A task is a basic building block in a :ref: `BehaviorTree<class_BehaviorTree>` that represents a specific behavior or control flow. Tasks are used to create complex behaviors by combining and nesting them in a hierarchy.
A task can be one of the following types: action, condition, composite, or decorator. Each type of task has its own corresponding subclass: :ref: `BTAction<class_BTAction>` , :ref: `BTCondition<class_BTCondition>` , :ref: `BTDecorator<class_BTDecorator>` , :ref: `BTComposite<class_BTComposite>` .
Tasks perform their work and return their status using the :ref: `_tick<class_BTTask_private_method__tick>` method. Status values are defined in :ref: `Status<enum_BT_Status>` . Tasks can be initialized using the :ref: `_setup<class_BTTask_private_method__setup>` method. See also :ref: `_enter<class_BTTask_private_method__enter>` & :ref: `_exit<class_BTTask_private_method__exit>` .
\ **Note:** Do not extend **BTTask** directly for your own tasks. Instead, extend one of the subtypes mentioned above.
.. rst-class :: classref-reftable-group
Properties
----------
.. table ::
:widths: auto
+-------------------------------------+---------------------------------------------------------+--------+
2024-07-20 15:25:24 +00:00
| `` Node `` | :ref: `agent<class_BTTask_property_agent>` | |
2024-01-12 20:05:50 +00:00
+-------------------------------------+---------------------------------------------------------+--------+
| :ref: `Blackboard<class_Blackboard>` | :ref: `blackboard<class_BTTask_property_blackboard>` | |
+-------------------------------------+---------------------------------------------------------+--------+
2024-07-20 15:25:24 +00:00
| `` String `` | :ref: `custom_name<class_BTTask_property_custom_name>` | `` "" `` |
2024-01-12 20:05:50 +00:00
+-------------------------------------+---------------------------------------------------------+--------+
2024-07-20 15:25:24 +00:00
| `` float `` | :ref: `elapsed_time<class_BTTask_property_elapsed_time>` | |
2024-01-12 20:05:50 +00:00
+-------------------------------------+---------------------------------------------------------+--------+
2024-07-20 15:25:24 +00:00
| `` Node `` | :ref: `scene_root<class_BTTask_property_scene_root>` | |
2024-05-02 11:39:19 +00:00
+-------------------------------------+---------------------------------------------------------+--------+
2024-01-12 20:05:50 +00:00
| :ref: `Status<enum_BT_Status>` | :ref: `status<class_BTTask_property_status>` | |
+-------------------------------------+---------------------------------------------------------+--------+
.. rst-class :: classref-reftable-group
Methods
-------
.. table ::
:widths: auto
2024-07-20 15:25:24 +00:00
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref: `_enter<class_BTTask_private_method__enter>` \ (\ ) |virtual| |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref: `_exit<class_BTTask_private_method__exit>` \ (\ ) |virtual| |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| `` String `` | :ref: `_generate_name<class_BTTask_private_method__generate_name>` \ (\ ) |virtual| |const| |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| `` PackedStringArray `` | :ref: `_get_configuration_warnings<class_BTTask_private_method__get_configuration_warnings>` \ (\ ) |virtual| |const| |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref: `_setup<class_BTTask_private_method__setup>` \ (\ ) |virtual| |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref: `Status<enum_BT_Status>` | :ref: `_tick<class_BTTask_private_method__tick>` \ (\ delta\: `` float ` ` \ ) |virtual| |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref: `abort<class_BTTask_method_abort>` \ (\ ) |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref: `add_child<class_BTTask_method_add_child>` \ (\ task\: :ref: `BTTask<class_BTTask>` \ ) |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref: `add_child_at_index<class_BTTask_method_add_child_at_index>` \ (\ task\: :ref: `BTTask<class_BTTask>` , idx\: `` int ` ` \ ) |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref: `BTTask<class_BTTask>` | :ref: `clone<class_BTTask_method_clone>` \ (\ ) |const| |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref: `BehaviorTree<class_BehaviorTree>` | :ref: `editor_get_behavior_tree<class_BTTask_method_editor_get_behavior_tree>` \ (\ ) |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref: `Status<enum_BT_Status>` | :ref: `execute<class_BTTask_method_execute>` \ (\ delta\: `` float ` ` \ ) |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref: `BTTask<class_BTTask>` | :ref: `get_child<class_BTTask_method_get_child>` \ (\ idx\: `` int ` ` \ ) |const| |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| `` int `` | :ref: `get_child_count<class_BTTask_method_get_child_count>` \ (\ ) |const| |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| `` int `` | :ref: `get_child_count_excluding_comments<class_BTTask_method_get_child_count_excluding_comments>` \ (\ ) |const| |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| `` int `` | :ref: `get_index<class_BTTask_method_get_index>` \ (\ ) |const| |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref: `BTTask<class_BTTask>` | :ref: `get_parent<class_BTTask_method_get_parent>` \ (\ ) |const| |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref: `BTTask<class_BTTask>` | :ref: `get_root<class_BTTask_method_get_root>` \ (\ ) |const| |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| `` String `` | :ref: `get_task_name<class_BTTask_method_get_task_name>` \ (\ ) |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| `` bool `` | :ref: `has_child<class_BTTask_method_has_child>` \ (\ task\: :ref: `BTTask<class_BTTask>` \ ) |const| |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref: `initialize<class_BTTask_method_initialize>` \ (\ agent\: `` Node `` , blackboard\: :ref: `Blackboard<class_Blackboard>` , scene_root\: `` Node ` ` \ ) |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| `` bool `` | :ref: `is_descendant_of<class_BTTask_method_is_descendant_of>` \ (\ task\: :ref: `BTTask<class_BTTask>` \ ) |const| |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| `` bool `` | :ref: `is_root<class_BTTask_method_is_root>` \ (\ ) |const| |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref: `BTTask<class_BTTask>` | :ref: `next_sibling<class_BTTask_method_next_sibling>` \ (\ ) |const| |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref: `print_tree<class_BTTask_method_print_tree>` \ (\ initial_tabs\: `` int `` = 0\ ) |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref: `remove_child<class_BTTask_method_remove_child>` \ (\ task\: :ref: `BTTask<class_BTTask>` \ ) |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref: `remove_child_at_index<class_BTTask_method_remove_child_at_index>` \ (\ idx\: `` int ` ` \ ) |
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
2024-01-12 20:05:50 +00:00
.. rst-class :: classref-section-separator
----
.. rst-class :: classref-descriptions-group
Property Descriptions
---------------------
.. _class_BTTask_property_agent:
.. rst-class :: classref-property
2024-07-20 15:25:24 +00:00
`` Node `` **agent** :ref: `🔗<class_BTTask_property_agent>`
2024-01-12 20:05:50 +00:00
.. rst-class :: classref-property-setget
2024-07-20 15:25:24 +00:00
- |void| **set_agent** \ (\ value\: `` Node ` ` \ )
- `` Node `` **get_agent** \ (\ )
2024-01-12 20:05:50 +00:00
2024-05-02 17:35:42 +00:00
The agent is the contextual object for the :ref: `BehaviorTree<class_BehaviorTree>` instance. This is usually the parent of the :ref: `BTPlayer<class_BTPlayer>` node that utilizes the :ref: `BehaviorTree<class_BehaviorTree>` resource.
2024-01-12 20:05:50 +00:00
.. rst-class :: classref-item-separator
----
.. _class_BTTask_property_blackboard:
.. rst-class :: classref-property
2024-07-20 15:25:24 +00:00
:ref: `Blackboard<class_Blackboard>` **blackboard** :ref: `🔗<class_BTTask_property_blackboard>`
2024-01-12 20:05:50 +00:00
.. rst-class :: classref-property-setget
2024-07-20 15:25:24 +00:00
- :ref: `Blackboard<class_Blackboard>` **get_blackboard** \ (\ )
2024-01-12 20:05:50 +00:00
Provides access to the :ref: `Blackboard<class_Blackboard>` . Blackboard is used to share data among tasks of the associated :ref: `BehaviorTree<class_BehaviorTree>` .
See :ref: `Blackboard<class_Blackboard>` for additional info.
.. rst-class :: classref-item-separator
----
.. _class_BTTask_property_custom_name:
.. rst-class :: classref-property
2024-07-20 15:25:24 +00:00
`` String `` **custom_name** = `` "" `` :ref: `🔗<class_BTTask_property_custom_name>`
2024-01-12 20:05:50 +00:00
.. rst-class :: classref-property-setget
2024-07-20 15:25:24 +00:00
- |void| **set_custom_name** \ (\ value\: `` String ` ` \ )
- `` String `` **get_custom_name** \ (\ )
2024-01-12 20:05:50 +00:00
User-provided name for the task. If not empty, it is used by the editor to represent the task. See :ref: `get_task_name<class_BTTask_method_get_task_name>` .
.. rst-class :: classref-item-separator
----
.. _class_BTTask_property_elapsed_time:
.. rst-class :: classref-property
2024-07-20 15:25:24 +00:00
`` float `` **elapsed_time** :ref: `🔗<class_BTTask_property_elapsed_time>`
2024-01-12 20:05:50 +00:00
.. rst-class :: classref-property-setget
2024-07-20 15:25:24 +00:00
- `` float `` **get_elapsed_time** \ (\ )
2024-01-12 20:05:50 +00:00
Elapsed time since the task was "entered". See :ref: `_enter<class_BTTask_private_method__enter>` .
Returns `` 0 `` when task is not `` RUNNING `` .
.. rst-class :: classref-item-separator
----
2024-05-02 11:39:19 +00:00
.. _class_BTTask_property_scene_root:
.. rst-class :: classref-property
2024-07-20 15:25:24 +00:00
`` Node `` **scene_root** :ref: `🔗<class_BTTask_property_scene_root>`
2024-05-02 11:39:19 +00:00
.. rst-class :: classref-property-setget
2024-07-20 15:25:24 +00:00
- `` Node `` **get_scene_root** \ (\ )
2024-05-02 11:39:19 +00:00
2024-05-02 17:35:42 +00:00
Root node of the scene the behavior tree is used in (e.g., the owner of the :ref: `BTPlayer<class_BTPlayer>` node). Can be uses to retrieve `` NodePath `` references.
2024-05-02 11:39:19 +00:00
\ **Example:** \
::
extends BTAction
@export var node_path: NodePath
func _setup():
var node: Node = scene_root.get_node(node_path)
.. rst-class :: classref-item-separator
----
2024-01-12 20:05:50 +00:00
.. _class_BTTask_property_status:
.. rst-class :: classref-property
2024-07-20 15:25:24 +00:00
:ref: `Status<enum_BT_Status>` **status** :ref: `🔗<class_BTTask_property_status>`
2024-01-12 20:05:50 +00:00
.. rst-class :: classref-property-setget
2024-07-20 15:25:24 +00:00
- :ref: `Status<enum_BT_Status>` **get_status** \ (\ )
2024-01-12 20:05:50 +00:00
Last execution :ref: `Status<enum_BT_Status>` returned by :ref: `_tick<class_BTTask_private_method__tick>` .
.. rst-class :: classref-section-separator
----
.. rst-class :: classref-descriptions-group
Method Descriptions
-------------------
.. _class_BTTask_private_method__enter:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
|void| **_enter** \ (\ ) |virtual| :ref: `🔗<class_BTTask_private_method__enter>`
2024-01-12 20:05:50 +00:00
Called when task is "entered", i.e. when task is executed while not having a `` RUNNING `` :ref: `status<class_BTTask_property_status>` .
It is called before :ref: `_tick<class_BTTask_private_method__tick>` in the execution order. This method is used when preparation is needed before main work begins, usually when it takes more than one tick to finish the task. See also :ref: `execute<class_BTTask_method_execute>` .
.. rst-class :: classref-item-separator
----
.. _class_BTTask_private_method__exit:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
|void| **_exit** \ (\ ) |virtual| :ref: `🔗<class_BTTask_private_method__exit>`
2024-01-12 20:05:50 +00:00
Called when task is "exited", i.e. after :ref: `_tick<class_BTTask_private_method__tick>` returns `` SUCCESS `` or `` FAILURE `` status. See also :ref: `execute<class_BTTask_method_execute>` .
.. rst-class :: classref-item-separator
----
.. _class_BTTask_private_method__generate_name:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
`` String `` **_generate_name** \ (\ ) |virtual| |const| :ref: `🔗<class_BTTask_private_method__generate_name>`
2024-01-12 20:05:50 +00:00
Called to generate a display name for the task unless :ref: `custom_name<class_BTTask_property_custom_name>` is set. See :ref: `get_task_name<class_BTTask_method_get_task_name>` .
.. rst-class :: classref-item-separator
----
2024-01-16 10:18:18 +00:00
.. _class_BTTask_private_method__get_configuration_warnings:
2024-01-12 20:05:50 +00:00
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
`` PackedStringArray `` **_get_configuration_warnings** \ (\ ) |virtual| |const| :ref: `🔗<class_BTTask_private_method__get_configuration_warnings>`
2024-01-12 20:05:50 +00:00
The string returned by this method is shown as a warning message in the behavior tree editor. Any task script that overrides this method must include `` @tool `` annotation at the top of the file.
.. rst-class :: classref-item-separator
----
.. _class_BTTask_private_method__setup:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
|void| **_setup** \ (\ ) |virtual| :ref: `🔗<class_BTTask_private_method__setup>`
2024-01-12 20:05:50 +00:00
Called to initialize a task during initialization step. It is called only once before the task's first execution tick. This method allows you to set up any necessary state or configurations for the task before it begins executing.
.. rst-class :: classref-item-separator
----
.. _class_BTTask_private_method__tick:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
:ref:`Status<enum_BT_Status>` **_tick**\ (\ delta\: ``float``\ ) |virtual| :ref:`🔗<class_BTTask_private_method__tick>`
2024-01-12 20:05:50 +00:00
Called when task is "ticked", i.e. executed by :ref: `BTPlayer<class_BTPlayer>` or :ref: `BTState<class_BTState>` during an update.
Returns execution status as defined in :ref: `Status<enum_BT_Status>` .
\ **Note:** Tasks perform their main function by implementing this method.
.. rst-class :: classref-item-separator
----
.. _class_BTTask_method_abort:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
|void| **abort** \ (\ ) :ref: `🔗<class_BTTask_method_abort>`
2024-01-12 20:05:50 +00:00
Resets the task and its children recursively. If a task is in the `` RUNNING `` state, it is exited and its status is reset to `` FRESH `` .
.. rst-class :: classref-item-separator
----
.. _class_BTTask_method_add_child:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
|void| **add_child** \ (\ task\: :ref: `BTTask<class_BTTask>` \ ) :ref: `🔗<class_BTTask_method_add_child>`
2024-01-12 20:05:50 +00:00
2024-03-04 20:36:16 +00:00
Adds a child task. The `` task `` is placed at the end of the children list.
2024-01-12 20:05:50 +00:00
.. rst-class :: classref-item-separator
----
.. _class_BTTask_method_add_child_at_index:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
|void| **add_child_at_index** \ (\ task\: :ref: `BTTask<class_BTTask>` , idx\: `` int ` ` \ ) :ref: ` 🔗<class_BTTask_method_add_child_at_index> `
2024-01-12 20:05:50 +00:00
2024-03-04 20:36:16 +00:00
Adds a child task. The `` task `` is placed at `` idx `` position in the children list.
2024-01-12 20:05:50 +00:00
.. rst-class :: classref-item-separator
----
.. _class_BTTask_method_clone:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
:ref: `BTTask<class_BTTask>` **clone** \ (\ ) |const| :ref: `🔗<class_BTTask_method_clone>`
2024-01-12 20:05:50 +00:00
Duplicates the task and its children, copying the exported members. Sub-resources are shared for efficiency, except for :ref: `BBParam<class_BBParam>` subtypes, which are always copied. Used by the editor to instantiate :ref: `BehaviorTree<class_BehaviorTree>` and copy-paste tasks.
.. rst-class :: classref-item-separator
----
2024-05-15 18:58:38 +00:00
.. _class_BTTask_method_editor_get_behavior_tree:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
:ref: `BehaviorTree<class_BehaviorTree>` **editor_get_behavior_tree** \ (\ ) :ref: `🔗<class_BTTask_method_editor_get_behavior_tree>`
2024-05-15 18:58:38 +00:00
Returns the behavior tree that owns this task. This is only available in the editor.
.. rst-class :: classref-item-separator
----
2024-01-12 20:05:50 +00:00
.. _class_BTTask_method_execute:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
:ref:`Status<enum_BT_Status>` **execute**\ (\ delta\: ``float``\ ) :ref:`🔗<class_BTTask_method_execute>`
2024-01-12 20:05:50 +00:00
Performs task's execution. The execution follows a specific sequence:
- If task's current :ref: `status<class_BTTask_property_status>` is not `` RUNNING `` , the :ref: `_enter<class_BTTask_private_method__enter>` method is called first.
- Next, the :ref: `_tick<class_BTTask_private_method__tick>` method is called next to perform the task's work.
- If the :ref: `_tick<class_BTTask_private_method__tick>` method returns `` SUCCESS `` or `` FAILURE `` status, the :ref: `_exit<class_BTTask_private_method__exit>` method will be called next as part of the execution cleanup.
.. rst-class :: classref-item-separator
----
.. _class_BTTask_method_get_child:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
:ref:`BTTask<class_BTTask>` **get_child**\ (\ idx\: ``int``\ ) |const| :ref:`🔗<class_BTTask_method_get_child>`
2024-01-12 20:05:50 +00:00
Returns a child task by specifying its index.
.. rst-class :: classref-item-separator
----
.. _class_BTTask_method_get_child_count:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
`` int `` **get_child_count** \ (\ ) |const| :ref: `🔗<class_BTTask_method_get_child_count>`
2024-01-12 20:05:50 +00:00
Returns the number of child tasks.
.. rst-class :: classref-item-separator
----
.. _class_BTTask_method_get_child_count_excluding_comments:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
`` int `` **get_child_count_excluding_comments** \ (\ ) |const| :ref: `🔗<class_BTTask_method_get_child_count_excluding_comments>`
2024-01-12 20:05:50 +00:00
Returns the number of child tasks not counting :ref: `BTComment<class_BTComment>` tasks.
.. rst-class :: classref-item-separator
----
.. _class_BTTask_method_get_index:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
`` int `` **get_index** \ (\ ) |const| :ref: `🔗<class_BTTask_method_get_index>`
2024-01-12 20:05:50 +00:00
Returns the task's position in the behavior tree branch. Returns `` -1 `` if the task doesn't belong to a task tree, i.e. doesn't have a parent.
.. rst-class :: classref-item-separator
----
.. _class_BTTask_method_get_parent:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
:ref: `BTTask<class_BTTask>` **get_parent** \ (\ ) |const| :ref: `🔗<class_BTTask_method_get_parent>`
2024-01-12 20:05:50 +00:00
Returns the task's parent.
.. rst-class :: classref-item-separator
----
.. _class_BTTask_method_get_root:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
:ref: `BTTask<class_BTTask>` **get_root** \ (\ ) |const| :ref: `🔗<class_BTTask_method_get_root>`
2024-01-12 20:05:50 +00:00
Returns the root task of the behavior tree.
.. rst-class :: classref-item-separator
----
.. _class_BTTask_method_get_task_name:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
`` String `` **get_task_name** \ (\ ) :ref: `🔗<class_BTTask_method_get_task_name>`
2024-01-12 20:05:50 +00:00
The string returned by this method is used to represent the task in the editor.
Method :ref: `_generate_name<class_BTTask_private_method__generate_name>` is called to generate a display name for the task unless :ref: `custom_name<class_BTTask_property_custom_name>` is set.
.. rst-class :: classref-item-separator
----
.. _class_BTTask_method_has_child:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
`` bool `` **has_child** \ (\ task\: :ref: `BTTask<class_BTTask>` \ ) |const| :ref: `🔗<class_BTTask_method_has_child>`
2024-01-12 20:05:50 +00:00
2024-03-04 20:36:16 +00:00
Returns `` true `` if `` task `` is a child of this task.
2024-01-12 20:05:50 +00:00
.. rst-class :: classref-item-separator
----
.. _class_BTTask_method_initialize:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
|void| **initialize** \ (\ agent\: `` Node `` , blackboard\: :ref: `Blackboard<class_Blackboard>` , scene_root\: `` Node ` ` \ ) :ref: ` 🔗<class_BTTask_method_initialize> `
2024-01-12 20:05:50 +00:00
Initilizes the task. Assigns :ref: `agent<class_BTTask_property_agent>` and :ref: `blackboard<class_BTTask_property_blackboard>` , and calls :ref: `_setup<class_BTTask_private_method__setup>` for the task and its children.
2024-05-02 11:39:19 +00:00
The method is called recursively for each child task. `` scene_root `` should be the root node of the scene the behavior tree is used in (e.g., the owner of the node that contains the behavior tree).
2024-01-12 20:05:50 +00:00
.. rst-class :: classref-item-separator
----
.. _class_BTTask_method_is_descendant_of:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
`` bool `` **is_descendant_of** \ (\ task\: :ref: `BTTask<class_BTTask>` \ ) |const| :ref: `🔗<class_BTTask_method_is_descendant_of>`
2024-01-12 20:05:50 +00:00
2024-03-04 20:36:16 +00:00
Returns `` true `` if this task is a descendant of `` task `` . In other words, this task must be a child of `` task `` or one of its children or grandchildren.
2024-01-12 20:05:50 +00:00
.. rst-class :: classref-item-separator
----
.. _class_BTTask_method_is_root:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
`` bool `` **is_root** \ (\ ) |const| :ref: `🔗<class_BTTask_method_is_root>`
2024-01-12 20:05:50 +00:00
Returns `` true `` if this task is the root task of its behavior tree. A behavior tree can have only one root task.
.. rst-class :: classref-item-separator
----
.. _class_BTTask_method_next_sibling:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
:ref: `BTTask<class_BTTask>` **next_sibling** \ (\ ) |const| :ref: `🔗<class_BTTask_method_next_sibling>`
2024-01-12 20:05:50 +00:00
Returns the next task after this task in the parent's children list.
Returns `` null `` if this task has no parent or it is the last child in the parent's children list.
.. rst-class :: classref-item-separator
----
.. _class_BTTask_method_print_tree:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
|void| **print_tree** \ (\ initial_tabs\: `` int `` = 0\ ) :ref: `🔗<class_BTTask_method_print_tree>`
2024-01-12 20:05:50 +00:00
Prints the subtree that starts with this task to the console.
.. rst-class :: classref-item-separator
----
.. _class_BTTask_method_remove_child:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
|void| **remove_child** \ (\ task\: :ref: `BTTask<class_BTTask>` \ ) :ref: `🔗<class_BTTask_method_remove_child>`
2024-01-12 20:05:50 +00:00
2024-03-04 20:36:16 +00:00
Removes `` task `` from children.
2024-01-12 20:05:50 +00:00
.. rst-class :: classref-item-separator
----
.. _class_BTTask_method_remove_child_at_index:
.. rst-class :: classref-method
2024-07-20 15:25:24 +00:00
|void| **remove_child_at_index** \ (\ idx\: `` int ` ` \ ) :ref: ` 🔗<class_BTTask_method_remove_child_at_index> `
2024-01-12 20:05:50 +00:00
Removes a child task at a specified index from children.
.. |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.)`
2024-07-20 15:25:24 +00:00
.. |void| replace :: :abbr: `void (No return value.)`