Улучшен поиск путей

This commit is contained in:
Евгений Титаренко 2023-08-21 21:27:22 +03:00
parent 3e60215e11
commit 26cc09241f
8 changed files with 107 additions and 18 deletions

View file

@ -27,5 +27,10 @@ shape = SubResource("CircleShape2D_v67co")
position = Vector2(-2, 0)
shape = SubResource("CircleShape2D_smr3g")
[node name="NavigationAgent2D" type="NavigationAgent2D" parent="."]
avoidance_enabled = true
debug_use_custom = true
debug_path_custom_color = Color(0, 0, 1, 1)
[connection signal="body_entered" from="Area2D" to="." method="_OnEntered"]
[connection signal="body_exited" from="Area2D" to="." method="_OnExited"]

View file

@ -4,7 +4,7 @@
[ext_resource type="Script" path="res://scripts/enemies/LivingArmor.cs" id="1_ofbsx"]
[ext_resource type="PackedScene" uid="uid://cf0wpahgwygxx" path="res://prefabs/light_sense.tscn" id="2_xkyos"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_d1ojb"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_8sbby"]
size = Vector2(15, 15)
[sub_resource type="CircleShape2D" id="CircleShape2D_ex1co"]
@ -33,7 +33,7 @@ polygon = PackedVector2Array(-7, -4, -7, 15, 8, 15, 8, -4, 5, -11, -4, -11)
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0.5, 7.5)
shape = SubResource("RectangleShape2D_d1ojb")
shape = SubResource("RectangleShape2D_8sbby")
[node name="AreaOfSight" type="Area2D" parent="."]
@ -47,6 +47,11 @@ monitorable = false
position = Vector2(1, 8)
shape = SubResource("CircleShape2D_62y1x")
[node name="NavigationAgent2D" type="NavigationAgent2D" parent="."]
path_desired_distance = 0.1
target_desired_distance = 0.1
avoidance_enabled = true
[connection signal="area_entered" from="LightSense" to="." method="_OnLightEntered"]
[connection signal="area_exited" from="LightSense" to="." method="_OnLightExited"]
[connection signal="body_entered" from="AreaOfSight" to="." method="_OnBodyEntered"]

View file

@ -1,11 +1,11 @@
[gd_scene load_steps=6 format=3 uid="uid://bmyjqerhno5vi"]
[ext_resource type="SpriteFrames" uid="uid://blijqhtsnyq7n" path="res://sprites/enemies/wretched/wretched.tres" id="1_aqrsj"]
[ext_resource type="SpriteFrames" uid="uid://cisc0k30gpx1q" path="res://sprites/enemies/wretched/wretched.tres" id="1_aqrsj"]
[ext_resource type="Script" path="res://scripts/enemies/Wretched.cs" id="1_ec388"]
[ext_resource type="PackedScene" uid="uid://cf0wpahgwygxx" path="res://prefabs/light_sense.tscn" id="2_16fib"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_svj4b"]
size = Vector2(24, 16)
size = Vector2(15, 15)
[sub_resource type="CircleShape2D" id="CircleShape2D_nortt"]
radius = 15.0
@ -28,7 +28,7 @@ frame_progress = 0.776966
polygon = PackedVector2Array(-5, -16, -7, -3, -7, 9, -11, 14, -11, 16, 8, 16, 8, 8, 7, 4, 7, -16)
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(1, 8)
position = Vector2(0, 8)
shape = SubResource("RectangleShape2D_svj4b")
[node name="PlayerCollision" type="Area2D" parent="."]
@ -38,5 +38,13 @@ monitorable = false
position = Vector2(1, 8)
shape = SubResource("CircleShape2D_nortt")
[node name="NavigationAgent2D" type="NavigationAgent2D" parent="."]
path_desired_distance = 0.1
target_desired_distance = 0.1
avoidance_enabled = true
avoidance_mask = 2
debug_use_custom = true
debug_path_custom_color = Color(0, 1, 0, 1)
[connection signal="area_entered" from="LightSense" to="." method="_OnLightEntered"]
[connection signal="body_entered" from="PlayerCollision" to="." method="_OnPlayerCollision"]