AttackingState ​
Inherits: ActionState < Resource
AttackingState represents the state when an entity is actively attacking a target. It manages transitions and facing logic, while the combat script handles ability usage.
Description ​
Key features:
- Manages transitions to other states (dead target, out of range, etc.)
- Handles entity orientation towards target with angle threshold
- Updates every 0.5 seconds via timer for performance
Variables ​
Timer | action_timer | |
Vector3 | last_face_position | Vector3.ZERO |
float | face_angle_threshold | deg_to_rad(15.0) |
float | action_interval | 0.5 |
Methods ​
void | enter() |
void | exit() |
void | update( _delta: float ) |
void | check_and_update_facing() |
bool | should_update_facing( target_position: Vector3 ) |
bool | is_in_attack_range() |
void | return_all_timer() |
Variable descriptions ​
Timer action_timer ​
Single timer for face direction updates
Vector3 last_face_position = Vector3.ZERO ​
Last position we faced toward
float face_angle_threshold = deg_to_rad(15.0) ​
Angle threshold for turning (in radians)
float action_interval = 0.5 ​
Action timer interval (in seconds)
Method descriptions ​
void enter() ​
Called when entering the attacking state
void exit() ​
Called when exiting the attacking state
void update( _delta: float ) ​
Called every frame to check state transitions
void check_and_update_facing() ​
Checks if facing needs updating and performs the update if needed
bool should_update_facing( target_position: Vector3 ) ​
Determines if we should update facing based on angle threshold
bool is_in_attack_range() ​
Checks if the entity is within attack range of its target
void return_all_timer() ​
Timer cleanup