WanderTask ​
Inherits: BehaviorTask < Resource
WanderTask provides simple wandering behavior around a central point. Entity will randomly move to nearby positions within a specified radius. Perfect for background NPCs that need basic ambient movement.
Properties ​
float | wander_radius | 5.0 |
Vector3 | wander_center | Vector3.ZERO |
float | min_wander_distance | 2.0 |
float | max_wander_distance | 5.0 |
bool | use_walk_speed | true |
float | min_idle_time | 3.0 |
float | max_idle_time | 8.0 |
float | max_wander_time | 0.0 |
Variables ​
Vector3 | current_target | Vector3.ZERO |
Timer | idle_timer | null |
Timer | wander_duration_timer | null |
bool | is_idling | false |
float | wander_start_time | 0.0 |
Methods ​
void | execute_task_start() |
void | execute_task_complete() |
void | execute_task_interrupt() |
void | execute_task_fail() |
void | handle_path_failure() |
void | cleanup_timers() |
bool | is_within_wander_bounds() |
void | set_wander_center( new_center: Vector3 ) |
Vector3 | get_wander_center() |
float | get_wander_radius() |
Property descriptions ​
Wander Settings
float wander_radius = 5.0 ​
Radius around the center point to wander within
Vector3 wander_center = Vector3.ZERO ​
Center point for wandering (Vector3.ZERO = use entity's start position)
float min_wander_distance = 2.0 ​
Minimum distance to move on each wander step
float max_wander_distance = 5.0 ​
Maximum distance to move on each wander step
bool use_walk_speed = true ​
Whether to use walking speed instead of running
Timing
float min_idle_time = 3.0 ​
Minimum time to wait at each location before moving again
float max_idle_time = 8.0 ​
Maximum time to wait at each location before moving again
float max_wander_time = 0.0 ​
Maximum time to spend wandering (0 = infinite)
Variable descriptions ​
Vector3 current_target = Vector3.ZERO ​
Current target position for this wander step
Timer idle_timer = null ​
Timer for idle periods between movements
Timer wander_duration_timer = null ​
Timer for maximum wander duration
bool is_idling = false ​
Whether we're currently in an idle phase
float wander_start_time = 0.0 ​
Starting time for this wander session
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.
void handle_path_failure() ​
When the point cannot be reached, picks a new one and tries again.
void cleanup_timers() ​
Frees the timers of the task.
bool is_within_wander_bounds() ​
Check if entity is currently within the wander bounds
void set_wander_center( new_center: Vector3 ) ​
Set a new wander center (useful for dynamic repositioning)
Vector3 get_wander_center() ​
Get current wander center
float get_wander_radius() ​
Get current wander radius