Skip to content

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 ​

floatwander_radius5.0
Vector3wander_centerVector3.ZERO
floatmin_wander_distance2.0
floatmax_wander_distance5.0
booluse_walk_speedtrue
floatmin_idle_time3.0
floatmax_idle_time8.0
floatmax_wander_time0.0

Variables ​

Vector3current_targetVector3.ZERO
Timeridle_timernull
Timerwander_duration_timernull
boolis_idlingfalse
floatwander_start_time0.0

Methods ​

voidexecute_task_start()
voidexecute_task_complete()
voidexecute_task_interrupt()
voidexecute_task_fail()
voidhandle_path_failure()
voidcleanup_timers()
boolis_within_wander_bounds()
voidset_wander_center( new_center: Vector3 )
Vector3get_wander_center()
floatget_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