BTPlayer
Inherits:
Player of BehaviorTree resources.
Description
BTPlayer node is used to instantiate and play BehaviorTree resources at runtime. During initialization, the behavior tree instance is given references to the agent, the blackboard, and the current scene root. The agent can be specified by the agent_node property (defaults to the BTPlayer’s parent node).
For an introduction to behavior trees, see BehaviorTree.
Properties
bool |
|
|
NodePath |
|
|
bool |
|
|
|
Methods
int |
get_last_status ( ) const |
void |
restart ( ) |
void |
update ( float delta ) |
Signals
behavior_tree_finished ( int status )
Emitted when the behavior tree has finished executing and returned SUCCESS
or FAILURE
.
Argument status
holds the status returned by the behavior tree. See Status.
updated ( int status )
Emitted when BTPlayer has finished the behavior tree update.
Argument status
holds the status returned by the behavior tree. See Status.
Enumerations
enum UpdateMode:
UpdateMode IDLE = 0
Execute behavior tree during the idle process.
UpdateMode PHYSICS = 1
Execute behavior tree during the physics process.
UpdateMode MANUAL = 2
Behavior tree is executed manually by calling update.
Property Descriptions
bool active = true
void set_active ( bool value )
bool get_active ( )
If true
, the behavior tree will be executed during update.
NodePath agent_node = NodePath("..")
void set_agent_node ( NodePath value )
NodePath get_agent_node ( )
Path to the node that will be used as the agent. Setting it after instantiation will have no effect.
BehaviorTree behavior_tree
void set_behavior_tree ( BehaviorTree value )
BehaviorTree get_behavior_tree ( )
BehaviorTree resource to instantiate and execute at runtime.
Blackboard blackboard
void set_blackboard ( Blackboard value )
Blackboard get_blackboard ( )
Holds data shared by the behavior tree tasks. See Blackboard.
BlackboardPlan blackboard_plan
void set_blackboard_plan ( BlackboardPlan value )
BlackboardPlan get_blackboard_plan ( )
Stores and manages variables that will be used in constructing new Blackboard instances.
bool monitor_performance = false
If true
, adds a performance monitor to “Debugger->Monitors” for each instance of this BTPlayer node.
UpdateMode update_mode = 1
void set_update_mode ( UpdateMode value )
UpdateMode get_update_mode ( )
Determines when the behavior tree is executed. See UpdateMode.
Method Descriptions
int get_last_status ( ) const
Returns the behavior tree’s last execution status. See Status.
BTTask get_tree_instance ( )
Returns the root task of the instantiated behavior tree.
void restart ( )
Resets the behavior tree’s execution. Each running task will be aborted and the next tree execution will start anew. This method does not reset Blackboard.
void update ( float delta )
Executes the root task of the behavior tree instance if active is true
. Call this method when update_mode is set to MANUAL. When update_mode is not MANUAL, the update will be called automatically. See UpdateMode.