Skip to content

InteractWithObjectTask ​

Inherits: BehaviorTask < Resource

Make entity interact with a specific interactable object by unique ID Enhanced with proper signal-based movement handling

Properties ​

inttarget_interactable_id0
boolmove_to_objecttrue
boolforce_walkingfalse
floatmax_interaction_distance2.0
boolface_objecttrue
floatwait_time0.0

Variables ​

InteractableObjecttarget_interactablenull
Vector3object_positionVector3.ZERO
floatinteraction_range2.0
boolmovement_completedfalse
boolfacing_completedfalse
boolobject_interaction_completedfalse
Timerwait_timernull
boolwaiting_after_interactionfalse

Methods ​

voidexecute_task_start()
voidexecute_task_complete()
voidexecute_task_interrupt()
voidexecute_task_fail()
InteractableObjectget_target_interactable()
floatget_distance_to_target()
boolis_in_interaction_range()
voidset_target_interactable_id( new_id: int )
boolis_target_accessible()
voidset_max_interaction_distance( distance: float )
voidcleanup_timers()

Property descriptions ​

Target

int target_interactable_id = 0 ​

The unique ID of the interactable to interact with

bool move_to_object = true ​

Whether to move to the object before interacting

bool force_walking = false ​

Whether to force walking instead of running

float max_interaction_distance = 2.0 ​

Maximum distance to attempt interaction from

bool face_object = true ​

Whether to face the object before interacting

Post-Interaction

float wait_time = 0.0 ​

Time to wait after interaction before completing (0 = complete immediately)

Variable descriptions ​

InteractableObject target_interactable = null ​

The object the entity interacts with.

Vector3 object_position = Vector3.ZERO ​

The position of the object.

float interaction_range = 2.0 ​

How close the entity must be to use the object.

bool movement_completed = false ​

True once the entity arrived.

bool facing_completed = false ​

True once the entity faces the object.

bool object_interaction_completed = false ​

True once the interaction is done.

Timer wait_timer = null ​

Timer for waiting after interaction

bool waiting_after_interaction = false ​

Whether we're currently waiting after interaction

Method descriptions ​

void execute_task_start() ​

Starts the task.

void execute_task_complete() ​

Called when the task finishes well.

void execute_task_interrupt() ​

Called when something interrupts the task.

void execute_task_fail() ​

Called when the task fails.

InteractableObject get_target_interactable() ​

The object the entity interacts with.

float get_distance_to_target() ​

The distance to the object (-1 when there is none).

bool is_in_interaction_range() ​

Is the entity close enough to use the object?

void set_target_interactable_id( new_id: int ) ​

Set the target interactable ID dynamically

bool is_target_accessible() ​

Check if target is currently accessible

void set_max_interaction_distance( distance: float ) ​

Set interaction distance dynamically

void cleanup_timers() ​

Frees the timers of the task.