idle works with avoidance
This commit is contained in:
@@ -5,7 +5,6 @@ class_name EnemyIdle
|
||||
@export var scan_cone_angle : float = 90
|
||||
@export var scan_time : float = 3
|
||||
|
||||
var idle_timer
|
||||
var scan_timer
|
||||
var scan_direction = scan_cone_angle/2
|
||||
|
||||
|
||||
@@ -66,10 +66,15 @@ func rotate_to_face2D(object,target,target_offset_angle,delta,turn_speed):
|
||||
func move_to_nav_point(delta):
|
||||
var destination = enemy.nav_agent.get_next_path_position()
|
||||
var local_destination = destination - enemy.global_position
|
||||
var direction = local_destination.normalized()
|
||||
enemy.velocity = direction * move_speed
|
||||
var new_velocity = local_destination.normalized() * move_speed
|
||||
|
||||
enemy.nav_agent.set_velocity(new_velocity)
|
||||
enemy.global_rotation.y = rotate_to_face2D(enemy,destination,0,delta,body_turn_speed)
|
||||
|
||||
func velocity_computed(safe_velocity):
|
||||
enemy.velocity = enemy.velocity.move_toward(safe_velocity,.25)
|
||||
|
||||
|
||||
func turret_look(target,delta):
|
||||
enemy.turret_look.global_rotation.y = rotate_to_face2D(enemy.turret_look,target,0,delta,turret_speed)
|
||||
|
||||
|
||||
@@ -172,3 +172,7 @@ func save():
|
||||
"health" : health
|
||||
}
|
||||
return save_dict
|
||||
|
||||
|
||||
func _on_navigation_agent_3d_velocity_computed(safe_velocity: Vector3) -> void:
|
||||
state_machine.current_state.velocity_computed(safe_velocity)
|
||||
|
||||
Reference in New Issue
Block a user