enemy reloads each bullet, added servo sound
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
extends EnemyState
|
||||
class_name EnemyIdle
|
||||
|
||||
@export var idle_speed : float = 1.5
|
||||
|
||||
var move_direction : Vector3
|
||||
var scan_direction : float
|
||||
@@ -19,11 +20,12 @@ func randomize_wander():
|
||||
wander_time = randf_range(1,3)
|
||||
|
||||
func randomize_turret_scan():
|
||||
scan_direction = randf_range(-TURRET_TURN_AMT,TURRET_TURN_AMT)
|
||||
scan_time = randf_range(5,10)
|
||||
scan_direction = -scan_direction
|
||||
|
||||
func _Enter():
|
||||
func Enter():
|
||||
super()
|
||||
randomize_wander()
|
||||
scan_direction = TURRET_TURN_AMT
|
||||
|
||||
func Update(delta: float):
|
||||
if wander_time > 0:
|
||||
@@ -42,12 +44,12 @@ func Physics_Update(delta : float):
|
||||
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.velocity = direction * idle_speed
|
||||
enemy.spider_look_next.look_at(destination)
|
||||
var look_target = enemy.spider_look_next.global_rotation.y
|
||||
enemy.global_rotation.y = lerp(enemy.global_rotation.y,look_target,delta * 3)
|
||||
|
||||
enemy.turret_look.rotation.y = lerp(enemy.turret_look.rotation.y,deg_to_rad(scan_direction),delta)
|
||||
enemy.turret_look.rotation.y = lerp(enemy.turret_look.rotation.y,enemy.spider_look_next.rotation.y + deg_to_rad(scan_direction),delta * enemy.turret_look_speed)
|
||||
|
||||
if enemy.turret_look.is_colliding() and enemy.turret_look.get_collider() is Player:
|
||||
Transitioned.emit(self,"attack")
|
||||
|
||||
Reference in New Issue
Block a user