Files
fps_project_1/scripts/EnemyStates.gd

26 lines
643 B
GDScript

extends State
class_name EnemyState
@export var enemy : CharacterBody3D
@export var move_speed : float = 3
@export var can_see : bool = false # indicates whether the enemy is able to see things in the state
func Update(delta):
if enemy.visibility_areas != null:
for area in enemy.visibility_areas:
var bodies = area.get_overlapping_bodies()
if bodies != null:
for i in bodies:
if i is Player:
enemy.character_follow = i
else:
enemy.character_follow = null
if enemy.character_follow != null:
if can_see:
if enemy.is_player_visible():
enemy.cache_player_pos()
Transitioned.emit(self,"attack")