IdleTask ​
Inherits: BehaviorTask < Resource
Modern IdleTask focused purely on positioning and waiting behavior. MovementStateManager automatically handles all movement and idle animations. This task simply ensures the entity is in the right location and orientation.
Description ​
FIXES APPLIED:
- Removed async/await movement calls
- Fixed navigation signal timing (setup BEFORE movement)
- Eliminated duplicate state tracking (single source of truth)
- Centralized signal management with automatic cleanup
- Unique timer naming to prevent conflicts
- Removed timer-based player detection (will use Area3D in EntityStateComponent)
Properties ​
Vector3 | idle_location | Vector3.ZERO |
bool | move_to_location | true |
float | position_threshold | 0.5 |
Vector3 | face_direction | Vector3.ZERO |
bool | use_default_face_direction | true |
float | face_delay | 1.0 |
bool | look_at_players | false |
float | look_at_player_chance | 0.3 |
Variables ​
bool | face_direction_initiated | false |
bool | facing_complete | false |
Timer | face_delay_timer | null |
Methods ​
void | execute_task_start() |
void | execute_task_complete() |
void | execute_task_interrupt() |
void | execute_task_fail() |
void | on_player_nearby( player: Player ) |
void | on_player_left( player: Player ) |
void | handle_path_failure() |
void | cleanup_timers() |
Property descriptions ​
Location
Vector3 idle_location = Vector3.ZERO ​
Location where the entity should idle (Vector3.ZERO = current position)
bool move_to_location = true ​
Whether to move to the idle location if not already there
float position_threshold = 0.5 ​
Position threshold for considering position reached
Facing
Vector3 face_direction = Vector3.ZERO ​
Direction to face while idle (Vector3.ZERO = no specific direction)
bool use_default_face_direction = true ​
Whether to use entity's default face direction if none specified
float face_delay = 1.0 ​
Time to wait after reaching position before starting to face direction
Behavior
bool look_at_players = false ​
Whether to look at nearby players occasionally (uses Area3D detection in EntityStateComponent)
float look_at_player_chance = 0.3 ​
Chance to look at player when they're nearby (0.0-1.0)
Variable descriptions ​
bool face_direction_initiated = false ​
Whether we've started the face direction process
bool facing_complete = false ​
Whether we're currently facing the target direction
Timer face_delay_timer = null ​
Timer for face delay
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 on_player_nearby( player: Player ) ​
Called by EntityStateComponent when player enters detection area
void on_player_left( player: Player ) ​
Called by EntityStateComponent when player leaves detection area
void handle_path_failure() ​
When there is no path to the idle place, the entity idles where it stands.
void cleanup_timers() ​
Frees the timers of the task.