Skip to content

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 ​

Timeraction_timer
Vector3last_face_positionVector3.ZERO
floatface_angle_thresholddeg_to_rad(15.0)
floataction_interval0.5

Methods ​

voidenter()
voidexit()
voidupdate( _delta: float )
voidcheck_and_update_facing()
boolshould_update_facing( target_position: Vector3 )
boolis_in_attack_range()
voidreturn_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