FollowEntityTask ​
Inherits: BehaviorTask < Resource
Follow an entity by unique ID with proper validation and error handling. Uses ObjectRegistry to find the target entity and fails gracefully if not found.
Properties ​
int | target_entity_id | 0 |
float | follow_distance | 3.0 |
float | max_follow_distance | 10.0 |
bool | use_formation_position | false |
bool | force_walking | false |
float | catch_up_threshold | 15.0 |
float | stop_following_distance | 1.5 |
float | update_interval | 0.5 |
Variables ​
Timer | follow_timer | null |
Entity | target_entity | null |
Vector3 | last_target_position | Vector3.ZERO |
bool | is_following | false |
float | last_validation_check | 0.0 |
float | validation_interval | 5.0 |
Methods ​
void | execute_task_start() |
void | execute_task_complete() |
void | execute_task_interrupt() |
void | execute_task_fail() |
Entity | get_target_entity() |
void | set_target_entity_id( new_id: int ) |
float | get_distance_to_target() |
void | cleanup_timers() |
Property descriptions ​
Follow Settings
int target_entity_id = 0 ​
Unique entity ID of the target to follow
float follow_distance = 3.0 ​
Distance to maintain from target
float max_follow_distance = 10.0 ​
Maximum distance before moving closer
bool use_formation_position = false ​
Whether to use formation positioning (for pets)
bool force_walking = false ​
Force walking even when far from target
Behavior
float catch_up_threshold = 15.0 ​
Distance at which to teleport to target (catch-up)
float stop_following_distance = 1.5 ​
Distance at which to stop moving closer
float update_interval = 0.5 ​
How often to update follow position (seconds)
Variable descriptions ​
Timer follow_timer = null ​
The timer that checks the followed entity.
Entity target_entity = null ​
The entity being followed.
Vector3 last_target_position = Vector3.ZERO ​
Where the followed entity was on the last check.
bool is_following = false ​
True while the entity follows.
float last_validation_check = 0.0 ​
The time of the last check that the followed entity is still there.
float validation_interval = 5.0 ​
Check target validity every 5 seconds
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.
Entity get_target_entity() ​
Get the current target entity (for external access)
void set_target_entity_id( new_id: int ) ​
Change the target entity ID (will re-validate on next update)
float get_distance_to_target() ​
Get current distance to target
void cleanup_timers() ​
Frees the timers of the task.