Files
fps_project_1/scripts/EnemySearch.gd
2025-05-02 15:52:07 -05:00

42 lines
896 B
GDScript

extends EnemyState
class_name EnemySearch
@export var scan_time : float = 3
@export var scan_cone_angle : float = 90
var scan_timer
var scan_direction = scan_cone_angle/2
func Enter():
scan_timer = scan_time
get_new_point_of_interest()
func Update(delta):
attack_on_sight()
#on timeout change scan direction
if scan_timer > 0:
scan_timer -= delta
else:
change_scan_direction()
func Physics_Update(delta):
#draw target for debug purposes
debug_marker(move_target)
#if navigation is finished get new point, otherwise continue on path
if enemy.nav_agent.is_navigation_finished():
if has_points_to_investigate():
get_new_point_of_interest()
else:
Transitioned.emit(self,"idle")
else:
move_to_nav_point(delta)
#do turret scan
turret_scan(Vector3(0,scan_direction,0),delta)
func change_scan_direction():
scan_timer = scan_time
scan_direction = -scan_direction