idle works with avoidance
This commit is contained in:
@@ -1094,8 +1094,7 @@ shape = SubResource("CylinderShape3D_gicen")
|
||||
[node name="NavigationAgent3D" type="NavigationAgent3D" parent="."]
|
||||
path_height_offset = 0.5
|
||||
avoidance_enabled = true
|
||||
radius = 2.0
|
||||
use_3d_avoidance = true
|
||||
radius = 1.0
|
||||
|
||||
[node name="Timers" type="Node" parent="."]
|
||||
|
||||
@@ -1150,6 +1149,7 @@ surface_material_override/0 = SubResource("StandardMaterial3D_1b3cb")
|
||||
|
||||
[connection signal="body_entered" from="body/backTarget" to="body/backTarget" method="_on_body_entered"]
|
||||
[connection signal="body_part_hit" from="body/backTarget" to="." method="_on_area_3d_body_part_hit"]
|
||||
[connection signal="velocity_computed" from="NavigationAgent3D" to="." method="_on_navigation_agent_3d_velocity_computed"]
|
||||
[connection signal="timeout" from="Timers/prefire_timer" to="." method="_on_prefire_timer_timeout"]
|
||||
[connection signal="timeout" from="Timers/postfire_timer" to="." method="_on_postfire_timer_timeout"]
|
||||
[connection signal="timeout" from="Timers/knocked_timer" to="." method="_on_knocked_timer_timeout"]
|
||||
|
||||
@@ -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