Navigation for enemies

This commit is contained in:
Marco 2025-01-31 15:05:45 +01:00
commit 076cff208d
7 changed files with 547 additions and 297 deletions

View file

@ -18,11 +18,12 @@ radius = 4.0
[sub_resource type="CircleShape2D" id="CircleShape2D_v711r"]
radius = 85.0529
[node name="Enemy" type="Area2D" node_paths=PackedStringArray("EquippedWeapon") groups=["Destroyable"]]
[node name="Enemy" type="CharacterBody2D" node_paths=PackedStringArray("EquippedWeapon") groups=["Destroyable"]]
collision_layer = 16
collision_mask = 9
script = ExtResource("1_lpwdj")
EquippedWeapon = NodePath("Weapon")
NavigationEnabled = true
metadata/_edit_group_ = true
[node name="Sprite2D" type="Sprite2D" parent="."]
@ -57,7 +58,12 @@ BulletCapacity = 4
BulletSpeed = 50.0
[node name="NavigationAgent2D" type="NavigationAgent2D" parent="."]
target_desired_distance = 64.0
path_max_distance = 800.0
path_postprocessing = 1
debug_enabled = true
debug_path_custom_color = Color(1, 0, 0, 1)
[connection signal="area_entered" from="." to="." method="_on_area_entered"]
[connection signal="area_entered" from="PlayerDetection" to="." method="_on_player_detection_area_entered"]
[connection signal="area_exited" from="PlayerDetection" to="." method="_on_player_detection_area_exited"]
[connection signal="velocity_computed" from="NavigationAgent2D" to="." method="_on_navigation_agent_2d_velocity_computed"]