Base class for [BehaviorTree] tasks. Base class for all [BehaviorTree] tasks. A task is a building block in a [BehaviorTree] that represents a specific behavior or control flow. It is the basic unit of the Behavior Tree (BT) and is used to create complex behaviors by combining and nesting tasks in a hierarchy. Tasks perform work and return their status with [method _tick]. See [enum TaskStatus]. A Task can be an action, a condition, a composite, or a decorator. Each type of task has its own corresponding subclass: [BTAction], [BTCondition], [BTDecorator], [BTComposite]. [b]Note:[/b] Do not extend [code]BTTask[/code] directly for your own tasks, instead extend one of the subtypes above. Called when task is "entered", i.e. when task is executed while not having a [constant RUNNING] [member status]. It is called before [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. Called when task is "exited", i.e. after [method _tick] returns [constant SUCCESS] or [constant FAILURE] status. When [member custom_name] is empty, the string returned by this method is used to display the task by the editor. See [method get_task_name]. The string returned by this method is displayed as a warning in the BT editor if the script that overrides it is a [code]tool[/code] script. Called when task is initialized during behavior tree initialization. Called when task is "ticked", i.e. executed by [BTPlayer] or [BTState] during update. Returns [member TaskStatus]. *Note:* Tasks perform their main function by implementing this method. Adds a child task. The [code]p_child[/code] is placed at the end of the children list. Adds a child task. The [code]p_child[/code] is placed at [code]p_idx[/code] position in the children list. Clones the task and its children with the exported members copied. Sub-resources are shared for efficiency, except for [BBParam] subtypes, which are always copied. Performs task's execution. During execution [method _enter] is called first, unless current task [member status] is [code]RUNNING[/code]. [method _tick] is called next to perform task's main function. If [constant SUCCESS] or [constant FAILURE] status is returned by [method _tick], [method _exit] will be called next. Returns a child task by its index. Returns the number of child tasks. Returns the child task's index. If [code]p_child[/code] is not a child of the task, [code]-1[/code] is returned instead. Returns task's parent. Returns the root task of the behavior tree. The string returned by this method is used to represent the task in the editor. [member custom_name] value is returned when it is not empty. Otherwise, the string constructed by [method _generate_name] is returned instead. Returns [code]true[/code] if [code]p_child[/code] is a child of this task. Initilizes the task. Assigns [member agent] and [member blackboard], and calls [method _setup] for the task and its children. The method is called recursively for each child task. Returns [code]true[/code] if this task is descendant of [code]p_task[/code]. I.e. this task must be a child of [code]p_task[/code] or one of its children or grandchildren. Returns [code]true[/code] if this task is the root task of the tree. A behavior tree can have only one root task. Returns the next task after this task in the children list of the [member parent]. Returns [code]null[/code] if this task has no parent or it is the last child in the parent's children list. Prints the subtree that starts with this task to console. Removes [code]p_child[/code] task from children. Removes a child task by index. The agent is a contextual object for the task's behavior tree instance. Usually, agent is the owner of a node with the [BehaviorTree] resource. Provides access to the blackboard for this task and behavior tree. Blackboard is used to share data among tasks of the associated behavior tree. See [Blackboard] for additional info. User provided name for the task. If not empty, [code]custom_name[/code] is used by the editor to display the task. See [method get_task_name]. Elapsed time since the task was entered. Returns 0 when task is not [code]RUNNING[/code]. Last execution [enum TaskStatus] returned by [method _tick]. Task wasn't executed yet or execution was cancelled. Task is being performed and hasn't finished yet. Task has finished with failure. Task has finished with success.