serious improvements on Ai and now has reload and rudimentary search
This commit is contained in:
@@ -1,2 +1,43 @@
|
||||
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():
|
||||
get_new_point_of_interest()
|
||||
else:
|
||||
move_to_nav_point(delta)
|
||||
|
||||
#do turret scan
|
||||
turret_look3D(delta)
|
||||
|
||||
func get_new_point_of_interest():
|
||||
if enemy.player_last_seen != null and enemy.player_last_seen != move_target:
|
||||
move_target = enemy.player_last_seen
|
||||
enemy.nav_agent.set_target_position(move_target)
|
||||
else:
|
||||
Transitioned.emit(self,"idle")
|
||||
|
||||
func change_scan_direction():
|
||||
scan_timer = scan_time
|
||||
scan_direction = -scan_direction
|
||||
|
||||
Reference in New Issue
Block a user