enemy stun is working now, needs timeout
This commit is contained in:
@@ -3,10 +3,44 @@ class_name EnemyStunned
|
||||
|
||||
@export var stunned_stars : Node
|
||||
|
||||
func _Enter():
|
||||
var move_direction : Vector3
|
||||
var scan_direction : float
|
||||
|
||||
var wander_time : float
|
||||
var scan_time : float
|
||||
|
||||
const WANDER_AMT = 50
|
||||
const TURRET_TURN_AMT : float = 180.0
|
||||
|
||||
func Enter():
|
||||
super()
|
||||
print("ENEMY STUNNED")
|
||||
if stunned_stars:
|
||||
stunned_stars.visible = true
|
||||
randomize_wander()
|
||||
|
||||
func _Exit():
|
||||
if stunned_stars:
|
||||
stunned_stars.visible = false
|
||||
|
||||
func Update(delta):
|
||||
if wander_time > 0:
|
||||
wander_time -= delta
|
||||
else:
|
||||
randomize_wander()
|
||||
|
||||
func Physics_Update(delta : float):
|
||||
if enemy:
|
||||
var destination = enemy.nav_agent.get_next_path_position()
|
||||
var local_destination = destination - enemy.global_position
|
||||
var direction = local_destination.normalized()
|
||||
if enemy.global_position.distance_to(local_destination) > 1:
|
||||
enemy.velocity = direction * move_speed
|
||||
enemy.global_rotation.y += delta
|
||||
|
||||
func randomize_wander():
|
||||
var x = randf_range(-WANDER_AMT,WANDER_AMT)
|
||||
var z = randf_range(-WANDER_AMT,WANDER_AMT)
|
||||
move_direction = enemy.global_position + Vector3(x,0,z)
|
||||
enemy.nav_agent.set_target_position(move_direction)
|
||||
wander_time = randf_range(1,3)
|
||||
|
||||
Reference in New Issue
Block a user