From 659ba0f94d720a42e5d7736356c6c4c29ede6c26 Mon Sep 17 00:00:00 2001 From: toasterpanic Date: Sat, 16 May 2026 14:05:49 -0400 Subject: [PATCH] Enemy avoidance (I finally figured it out <3), fix camera movement bugging out under specific circumstances --- scenes/dreamer.tscn | 50 +++++++++++++++++++++++++ scenes/game.tscn | 77 ++++++++++++++------------------------ scripts/enemies/dreamer.gd | 30 ++++++++++----- scripts/player.gd | 6 ++- scripts/player_camera.gd | 5 ++- 5 files changed, 106 insertions(+), 62 deletions(-) create mode 100644 scenes/dreamer.tscn diff --git a/scenes/dreamer.tscn b/scenes/dreamer.tscn new file mode 100644 index 0000000..f01e85f --- /dev/null +++ b/scenes/dreamer.tscn @@ -0,0 +1,50 @@ +[gd_scene format=3 uid="uid://cwpnnh7v4b5q2"] + +[ext_resource type="Script" uid="uid://vi18m3j6f6fa" path="res://scripts/enemies/dreamer.gd" id="1_pa2oe"] +[ext_resource type="PackedScene" uid="uid://cnii80nh1mxr2" path="res://scenes/living/dreamer_body.tscn" id="2_43va2"] +[ext_resource type="Texture2D" uid="uid://b6krbvbco0jt6" path="res://textures/shadow.png" id="3_n5vsr"] + +[sub_resource type="BoxShape3D" id="BoxShape3D_trtic"] +size = Vector3(0.65, 1, 0.65) + +[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_yqjtg"] +radius = 0.15 +height = 1.0 + +[node name="Dreamer" type="CharacterBody3D" unique_id=272925354] +collision_layer = 2 +collision_mask = 2 +script = ExtResource("1_pa2oe") + +[node name="HitCollision" type="Area3D" parent="." unique_id=258957044] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1500001, 0) +collision_layer = 0 + +[node name="Shape" type="CollisionShape3D" parent="HitCollision" unique_id=681211050] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.5) +shape = SubResource("BoxShape3D_trtic") + +[node name="DreamerBody" parent="." unique_id=723408850 instance=ExtResource("2_43va2")] + +[node name="Shadow" type="Sprite3D" parent="." unique_id=66990281] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2, 0) +modulate = Color(1, 1, 1, 0.5764706) +pixel_size = 0.03 +axis = 1 +texture_filter = 0 +texture = ExtResource("3_n5vsr") + +[node name="Collision" type="CollisionShape3D" parent="." unique_id=1709995346] +shape = SubResource("CapsuleShape3D_yqjtg") + +[node name="Floorcast" type="RayCast3D" parent="." unique_id=1016475353] +target_position = Vector3(0, -16, 0) + +[node name="Navigator" type="NavigationAgent3D" parent="." unique_id=919187616] +path_postprocessing = 2 +avoidance_enabled = true +neighbor_distance = 1.5 +max_speed = 2.5 +debug_enabled = true + +[connection signal="velocity_computed" from="Navigator" to="." method="_on_navigator_velocity_computed"] diff --git a/scenes/game.tscn b/scenes/game.tscn index fd542e7..0475d9c 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -4,7 +4,6 @@ [ext_resource type="Script" uid="uid://crf3d7dpjvlsl" path="res://scripts/player_camera.gd" id="1_lnu2h"] [ext_resource type="Script" uid="uid://66iq60cxqomg" path="res://scripts/player.gd" id="1_yqjtg"] [ext_resource type="Material" uid="uid://bivt02tm06osv" path="res://materials/tile/stone_floor.tres" id="2_gee14"] -[ext_resource type="Texture2D" uid="uid://cvtipichutylm" path="res://textures/test-sword.png" id="2_ir15t"] [ext_resource type="Material" uid="uid://bekoyi2mq1aiw" path="res://materials/tile/stone_wall.tres" id="3_dinhu"] [ext_resource type="Material" uid="uid://covj5ljosv6pt" path="res://materials/tile/stone_wall_small_rock.tres" id="4_kvuet"] [ext_resource type="Texture2D" uid="uid://b6krbvbco0jt6" path="res://textures/shadow.png" id="4_lbhrr"] @@ -13,13 +12,13 @@ [ext_resource type="PackedScene" uid="uid://co5p7h3exggvh" path="res://scenes/living/slime.tscn" id="6_u5sy4"] [ext_resource type="PackedScene" uid="uid://b6otq05jy7m6d" path="res://scenes/prefabs/brightshroom.tscn" id="9_vtaks"] [ext_resource type="PackedScene" uid="uid://boelsm35tk0k6" path="res://scenes/prefabs/brightshroom_orange.tscn" id="10_kvpfn"] -[ext_resource type="Script" uid="uid://vi18m3j6f6fa" path="res://scripts/enemies/dreamer.gd" id="12_trtic"] +[ext_resource type="PackedScene" uid="uid://cwpnnh7v4b5q2" path="res://scenes/dreamer.tscn" id="13_ca42v"] [ext_resource type="Texture2D" uid="uid://b8sc3vq5pmwil" path="res://textures/slime.png" id="14_trtic"] [ext_resource type="Script" uid="uid://btuscff4168hb" path="res://scripts/hide_node.gd" id="16_ca42v"] [sub_resource type="NavigationMesh" id="NavigationMesh_kvuet"] -vertices = PackedVector3Array(-7.5, 0.55766946, -7.5, -7.5, 0.55766946, 7.5, -6.5, 0.55766946, 7.5, -6.5, 0.55766946, -7.5, -5.5, 6.5576696, -7.5, -5.5, 6.5576696, 7.5, -4.45, 6.5576696, 7.5, -4.45, 6.5576696, -7.5, -2.1, 0.55766946, -1.75, -1.6999998, 0.55766946, -0.6999998, -1.4499998, 0.55766946, -0.5499997, 0.8000002, 0.55766946, -1.5499997, 1.1500006, 0.55766946, -1.7999997, 0.75, 0.55766946, -0.6999998, 0.6999998, 0.55766946, -1.3499999, -2.5499997, 0.6576695, -2.1, -2.35, 0.55766946, -2, 1.5, 0.55766946, -1.7999997, 1.5, 0.55766946, -7.5, -3.0499997, 0.9076695, -7.5, -2.4812498, 0.55766946, -7.5, -1.9985709, 0.55766946, -2.6038594, -2.303679, 0.55766946, -3.802743, -3.0499997, 0.9076695, -2.1, 2.1500006, 0.55766946, -0.5999999, 2.9499998, 0.55766946, 1.25, 3.1000004, 0.55766946, 1.1500006, 2.25, 0.55766946, -0.75, 1.8000002, 0.55766946, -1.7999997, 5.25, 0.55766946, 1.4000006, 5.3500004, 0.55766946, 1.9000006, 7.5, 0.55766946, 1.8500004, 2.25, 0.55766946, -1.3499999, 4.9000006, 0.55766946, 1.1500006, 2.1500006, 0.55766946, -1.5499997, 7.5, 0.55766946, -7.5, 1.3000002, 2.5576694, -1.1999998, 1.3000002, 2.5576694, -0.8499999, 1.6000004, 2.5576694, -0.8499999, 1.6000004, 2.6076694, -1.1999998, -1.25, 0.55766946, -0.4000001, -0.5499997, 0.55766946, 0.8500004, 1, 0.55766946, -0.4000001, -0.3499999, 0.55766946, 1.4000006, -0.7999997, 0.55766946, 1.9000006, -0.19999981, 0.55766946, 2.25, -0.3499999, 0.55766946, 1.1999998, 0.15000057, 0.55766946, 2.75, 2.6500006, 0.55766946, 1.6000004, 1.8000002, 0.55766946, -0.2999997, 1.1500006, 0.55766946, -0.2999997, 2.6500006, 0.55766946, 2.75, -3.25, 1.9576695, -0.4000001, -3.25, 1.9576695, 0.10000038, -3.1, 2.0576694, 0.05000019, -3.35, 1.8076694, 1.6000004, -3.35, 1.8076694, 2.75, -2.65, 1.6076694, 2.5, -3, 1.7076695, 1.5, 5.3500004, 0.55766946, 3.1000004, 7.5, 0.55766946, 3.1500006, -0.6500001, 0.55766946, 4.1500006, -0.5499997, 0.55766946, 4.25, -0.099999905, 0.55766946, 3.8500004, 0.05000019, 0.55766946, 3.1500006, 0.6000004, 0.55766946, 3.8500004, 2.75, 0.55766946, 3.5500002, 2.6500006, 0.55766946, 3.4000006, 0.19999981, 0.55766946, 3.75, -0.4499998, 7.0576696, 3.0500002, -0.4499998, 7.0576696, 3.9499998, 0.4499998, 7.0576696, 3.9499998, 0.4499998, 7.0576696, 3.0500002, 5.3500004, 0.55766946, 3.4000006, 5.1000004, 0.55766946, 3.75, 4.6500006, 0.55766946, 7.5, 7.5, 0.55766946, 7.5, 4.6000004, 0.55766946, 3.8500004, 0.9000006, 0.55766946, 4.2, 2.9499998, 0.55766946, 3.75, 1.0500002, 0.55766946, 4.5, 3.1000004, 0.55766946, 3.8500004, 0.9499998, 0.55766946, 5, 0.40000057, 0.55766946, 5.3500004, 0.15000057, 0.55766946, 7.5, 3.3500004, 0.55766946, 7.5, 3.4000006, 0.55766946, 3.8500004, 0.15000057, 0.55766946, 5.4000006, -0.5999999, 0.55766946, 4.6000004, -1, 0.55766946, 4.6000004, -1.9000001, 0.55766946, 7.25, -2.5, 0.6076694, 7.5, -1.1999998, 0.55766946, 4.7, -0.3499999, 0.55766946, 5.1500006, -1.5, 0.55766946, 4.6500006, -1.2999997, 0.55766946, 5.3500004, -0.19999981, 0.55766946, 5.3, -1.5999999, 0.55766946, 5.75, -1.5999999, 0.55766946, 6.8500004, -1.9000001, 0.55766946, 5.8500004, -0.049999714, 2.5576694, 4.45, 0.05000019, 2.5576694, 4.75, 0.4499998, 2.6076694, 4.6500006, 0.35000038, 2.6076694, 4.3, -3.25, 1.9576695, 4.6000004, -3.25, 1.9576695, 5.1500006, -3.1, 2.0576694, 5.1000004, -3.2999997, 1.8076694, 6.7, -2.75, 1.7076695, 6.55, -2.9, 1.7576694, 6, -3.2999997, 1.8076694, 5.8) -polygons = [PackedInt32Array(3, 2, 0), PackedInt32Array(0, 2, 1), PackedInt32Array(7, 6, 4), PackedInt32Array(4, 6, 5), PackedInt32Array(9, 8, 10), PackedInt32Array(10, 8, 11), PackedInt32Array(11, 8, 12), PackedInt32Array(14, 13, 10), PackedInt32Array(11, 14, 10), PackedInt32Array(20, 22, 19), PackedInt32Array(19, 22, 15), PackedInt32Array(15, 21, 16), PackedInt32Array(16, 21, 12), PackedInt32Array(12, 18, 17), PackedInt32Array(18, 22, 20), PackedInt32Array(22, 21, 15), PackedInt32Array(21, 22, 12), PackedInt32Array(12, 22, 18), PackedInt32Array(15, 23, 19), PackedInt32Array(12, 8, 16), PackedInt32Array(25, 24, 26), PackedInt32Array(26, 24, 27), PackedInt32Array(28, 17, 18), PackedInt32Array(31, 30, 29), PackedInt32Array(27, 32, 26), PackedInt32Array(26, 32, 33), PackedInt32Array(31, 29, 33), PackedInt32Array(34, 28, 18), PackedInt32Array(32, 34, 33), PackedInt32Array(33, 34, 31), PackedInt32Array(31, 34, 18), PackedInt32Array(31, 18, 35), PackedInt32Array(39, 38, 36), PackedInt32Array(36, 38, 37), PackedInt32Array(40, 10, 13), PackedInt32Array(42, 41, 13), PackedInt32Array(13, 41, 40), PackedInt32Array(45, 44, 43), PackedInt32Array(43, 46, 45), PackedInt32Array(45, 46, 47), PackedInt32Array(49, 48, 50), PackedInt32Array(50, 48, 51), PackedInt32Array(50, 51, 46), PackedInt32Array(46, 51, 47), PackedInt32Array(24, 25, 49), PackedInt32Array(49, 25, 48), PackedInt32Array(42, 50, 41), PackedInt32Array(41, 50, 46), PackedInt32Array(54, 53, 52), PackedInt32Array(58, 57, 55), PackedInt32Array(55, 57, 56), PackedInt32Array(30, 31, 59), PackedInt32Array(59, 31, 60), PackedInt32Array(62, 61, 63), PackedInt32Array(63, 61, 64), PackedInt32Array(67, 66, 65), PackedInt32Array(68, 63, 64), PackedInt32Array(68, 64, 65), PackedInt32Array(65, 64, 47), PackedInt32Array(65, 47, 67), PackedInt32Array(67, 47, 51), PackedInt32Array(72, 71, 69), PackedInt32Array(69, 71, 70), PackedInt32Array(73, 59, 60), PackedInt32Array(73, 60, 74), PackedInt32Array(74, 60, 76), PackedInt32Array(74, 76, 75), PackedInt32Array(75, 77, 74), PackedInt32Array(79, 78, 66), PackedInt32Array(66, 78, 65), PackedInt32Array(81, 80, 79), PackedInt32Array(79, 80, 78), PackedInt32Array(83, 82, 84), PackedInt32Array(84, 82, 85), PackedInt32Array(85, 82, 86), PackedInt32Array(83, 84, 87), PackedInt32Array(81, 86, 80), PackedInt32Array(80, 86, 82), PackedInt32Array(86, 77, 85), PackedInt32Array(85, 77, 75), PackedInt32Array(62, 88, 61), PackedInt32Array(61, 88, 89), PackedInt32Array(90, 84, 91), PackedInt32Array(89, 88, 92), PackedInt32Array(92, 88, 93), PackedInt32Array(94, 92, 95), PackedInt32Array(95, 92, 93), PackedInt32Array(95, 93, 96), PackedInt32Array(96, 87, 95), PackedInt32Array(95, 87, 97), PackedInt32Array(97, 87, 98), PackedInt32Array(98, 87, 84), PackedInt32Array(84, 90, 98), PackedInt32Array(97, 98, 99), PackedInt32Array(101, 100, 102), PackedInt32Array(102, 100, 103), PackedInt32Array(106, 105, 104), PackedInt32Array(108, 107, 109), PackedInt32Array(109, 107, 110)] +vertices = PackedVector3Array(-4.1668324, 6.5576696, -10.84375, -4.1668324, 6.5576696, -10.49375, 10.833168, 6.5576696, -10.49375, 10.833168, 6.5576696, -10.84375, -7.5168324, 0.55766946, -7.69375, -6.516833, 0.55766946, -7.69375, -6.516833, 0.55766946, -8.09375, -6.0668325, 0.55766946, -8.54375, -5.1668324, 0.55766946, -8.54375, -5.1668324, 0.55766946, -9.54375, -6.266833, 0.55766946, -8.44375, -7.5168324, 0.55766946, -9.54375, -3.6668324, 7.4576697, -3.94375, -3.7168326, 7.4076695, -3.6437497, -3.6168327, 7.3576694, -3.5437498, -3.4168324, 7.4076695, -4.04375, -2.7668324, 6.9076695, -3.49375, 1.8331671, 6.9076695, -8.09375, 1.2831678, 7.4076695, -8.74375, 1.1781673, 7.1076694, -8.04875, 2.0331678, 6.9076695, -8.19375, 2.4331675, 6.9076695, -8.19375, 2.4331675, 7.3576694, -8.99375, -3.6168327, 7.3576694, -3.0437498, -2.8668327, 6.9076695, -2.9937496, 1.4331675, 7.4576697, -9.04375, -2.7168322, 6.8576694, -8.14375, -2.8168325, 6.9076695, -7.79375, -2.1168327, 6.5576696, -7.39375, -2.2668324, 6.5576696, -7.58125, -2.3501663, 6.5576696, -7.5270834, -4.1668324, 7.3576694, -8.99375, -4.1668324, 7.1076694, -8.54375, -3.1168327, 7.1076694, -8.54375, -1.4168329, 6.8576694, -8.09375, -2.916833, 7.0576696, -8.44375, -1.7668324, 6.6076694, -7.74375, -0.06683254, 7.3576694, -8.99375, 10.833168, 6.9076695, -8.19375, 10.833168, 7.3576694, -8.99375, 4.2331676, 0.55766946, -6.54375, 4.833167, 0.55766946, -6.74375, 4.833167, 0.9076695, -8.39375, 2.5331678, 0.9076695, -8.39375, 2.333167, 0.55766946, -7.4937496, 4.833167, 0.55766946, -7.84375, 2.3831673, 0.55766946, -7.71875, 4.1861773, 0.55766946, -7.7399597, 2.0331678, 0.55766946, -6.84375, 7.9831676, 0.55766946, -7.79375, 8.383167, 0.55766946, -7.79375, 8.383167, 0.9076695, -8.39375, 7.783167, 0.55766946, -7.69375, 4.9831676, 0.55766946, -6.74375, 5.333168, 0.55766946, -6.49375, 4.8831673, 0.55766946, -7.84375, 6.8831787, 0.55766946, -7.7477627, 7.533167, 0.55766946, -7.34375, 5.583168, 0.55766946, -5.79375, 7.533167, 0.55766946, -5.79375, 10.833168, 0.55766946, -7.79375, 10.833168, 0.9076695, -8.39375, -3.1168327, 7.0576696, -7.54375, -2.7668324, 6.8576694, -6.74375, -2.279333, 6.5576696, -7.23125, -3.6168327, 7.3576694, -7.54375, -3.6168327, 7.3576694, -5.44375, -7.5168324, 0.55766946, -3.99375, -6.516833, 0.55766946, -4.94375, -10.516832, 6.5576696, 0.30625057, -10.216833, 6.5576696, 0.65625, -10.116833, 6.5576696, 0.65625, -5.1668324, 6.5576696, -4.29375, -5.6168327, 6.5576696, -4.54375, -5.1668324, 6.5576696, -7.54375, -5.516833, 6.5576696, -7.54375, -5.516833, 6.5576696, -4.74375, 0.48316765, 2.0576694, -6.6437497, 0.48316765, 2.0576694, -6.74375, 0.13316727, 2.1576693, -6.94375, -0.16683292, 2.2576694, -6.99375, -0.96683216, 2.2576694, -6.19375, 0.03316784, 1.9576695, -5.74375, 3.9831676, 0.55766946, -6.34375, 3.8831673, 0.55766946, -6.09375, 1.8831673, 0.55766946, -6.49375, 1.6831675, 0.55766946, -6.34375, 0.03316784, 0.55766946, -4.6437497, -0.31683254, 0.55766946, -4.84375, -0.71683216, 0.55766946, -3.84375, 0.53316784, 0.55766946, -4.74375, 1.9331675, 0.55766946, -3.84375, 3.583167, 0.55766946, -3.8937497, 4.583167, 0.55766946, -3.84375, 4.583167, 0.55766946, -5.09375, 4.1331673, 0.55766946, -5.34375, 1.2831678, 0.55766946, -6.24375, 0.68316746, 0.55766946, -4.8937497, 2.3831673, 0.55766946, -3.3937497, 2.3831673, 0.55766946, -1.9437494, 3.1331673, 0.55766946, -1.9437494, 3.1331673, 0.55766946, -3.44375, 3.2331676, 0.55766946, -3.6437497, 2.1331673, 0.55766946, -3.74375, 4.4831676, 2.5576694, -6.09375, 4.533168, 2.5576694, -5.74375, 4.9331684, 2.6076694, -5.84375, 4.833167, 2.6076694, -6.19375, 5.4331684, 0.55766946, -3.84375, 5.333168, 0.55766946, -5.34375, 5.6331673, 0.55766946, -3.74375, 5.8831673, 0.55766946, -3.3937497, 7.533167, 0.55766946, -3.1437502, 5.8831673, 0.55766946, -3.1437502, -2.2168322, 1.9576695, -4.79375, -2.0668325, 2.0576694, -4.69375, -1.9168329, 2.0076694, -4.94375, -1.9668322, 1.9576695, -5.04375, -3.3168325, 1.9076693, -3.74375, -3.2668328, 1.9576695, -3.2937498, -3.0668325, 2.0576694, -3.3937497, -3.1668324, 2.0076694, -3.7937498, 5.833168, 0.55766946, -1.59375, 5.6331673, 0.55766946, -1.2937498, 5.783167, 0.55766946, -1.2937498, 6.1331673, 0.55766946, -1.0437498, 6.2331676, 0.55766946, -0.5437498, 7.533167, 0.55766946, -0.5437498, -3.6168327, 7.3576694, 7.5062504, -2.8668327, 6.9076695, 7.5062504, -3.3168325, 1.8076694, -1.84375, -2.7168322, 1.7076695, -1.9937496, -2.8668327, 1.7076695, -2.4437494, -3.1668324, 1.7576694, -2.59375, -3.3168325, 1.8076694, -2.7937498, -5.516833, 6.5576696, 0.40625, -5.516833, 6.5576696, 0.7062502, -5.1668324, 6.5576696, 0.65625, -5.766833, 6.6576695, 0.056250572, -5.1668324, 6.8576694, -0.9937496, -5.5268326, 6.7576694, -0.3637495, -5.1668324, 6.5576696, -0.44374943, -6.7168326, 7.4076695, -0.7437496, -6.266833, 6.8576694, 0.056250572, -6.1168327, 6.8576694, -0.04374981, -4.8168325, 7.4076695, -2.6437502, -6.020825, 6.9576693, -0.5421572, -5.717828, 6.9576693, -0.8443546, -1.6168327, 0.55766946, -1.0437498, -1.8168325, 0.55766946, -1.1437502, -1.7168322, 0.55766946, -0.7437496, -0.46683216, 0.55766946, 1.6062498, -0.76683235, 0.55766946, 1.8062506, -0.76683235, 0.55766946, 1.90625, -0.06683254, 0.55766946, 2.3562498, -1.0668325, 0.55766946, -1.0437498, -1.2668324, 0.55766946, -0.44374943, -0.86683273, 0.55766946, -0.7937498, 5.033167, 0.55766946, 0.10624981, 4.7331676, 0.55766946, -0.24374962, 3.583167, 0.55766946, -1.1437502, 1.9331675, 0.55766946, -1.1437502, -0.36683273, 0.55766946, 1.15625, 0.083167076, 0.55766946, 2.5562506, 4.7331676, 0.55766946, -0.84375, 3.2331676, 0.55766946, -1.3937502, 2.2831678, 0.55766946, -1.3937502, -0.41683292, 0.55766946, -0.6937494, 0.13316727, 0.55766946, -1.1437502, 4.9331684, 0.55766946, -1.1437502, -0.86683273, 2.5576694, -1.59375, -0.6668329, 2.5576694, -1.2937498, -0.51683235, 2.5576694, -1.2937498, -0.26683235, 2.6076694, -1.5437498, -0.51683235, 2.5576694, -1.84375, -9.166833, 7.4076695, 1.7062502, -8.516832, 6.8576694, 2.3062506, 5.283167, 2.5576694, -0.6937494, 5.283167, 2.5576694, -0.34375, 5.583168, 2.5576694, -0.34375, 5.583168, 2.6076694, -0.6937494, -0.9168329, 0.55766946, 4.5062504, -0.9168329, 0.55766946, 4.5562506, -0.61683273, 0.55766946, 4.35625, 0.083167076, 0.55766946, 3.1062498, 6.2331676, 0.55766946, -0.24374962, 0.18316746, 0.55766946, 2.7062502, 5.1831684, 0.55766946, 0.20625019, -0.016832352, 0.55766946, 4.2562504, 0.33316708, 0.55766946, 4.5062504, 5.9831676, 0.55766946, 0.10624981, 0.48316765, 0.55766946, 4.8062496, 0.13316727, 0.55766946, 5.7562504, -0.36683273, 0.55766946, 5.90625, -0.36683273, 0.55766946, 7.5062504, 5.783167, 0.55766946, 0.20625019, 0.5831671, 0.55766946, 5.106251, 0.48316765, 0.55766946, 5.5062504, 7.533167, 0.55766946, 7.5062504, -3.2668328, 1.9576695, -0.44374943, -3.2668328, 1.9576695, 0.10624981, -3.1168327, 2.0076694, 0.056250572, -8.766832, 0.95766944, 2.0562506, -8.266832, 0.55766946, 2.6062498, -7.916833, 0.55766946, 2.5562506, -8.341833, 0.6576695, 2.3062506, -8.091833, 0.45766944, 2.5812502, -7.5168324, 0.55766946, 2.9562502, -7.5168324, 0.55766946, 3.3562498, -6.516833, 0.55766946, 3.3562498, -7.6168327, 0.55766946, 2.7562504, -6.5668325, 0.95766944, -0.14375019, -6.550166, 0.55766946, 1.0229168, -7.819818, 0.55766946, 2.1544352, -5.516833, 6.5576696, 7.5062504, -5.1668324, 6.5576696, 7.5062504, -3.3168325, 1.8076694, 1.5562506, -3.3168325, 1.8076694, 2.7562504, -2.666833, 1.6576693, 2.5062504, -3.0168324, 1.7076695, 1.4562502, -0.46683216, 7.0576696, 3.0562506, -0.46683216, 7.0576696, 3.9562502, 0.48316765, 7.0576696, 3.9562502, 0.48316765, 7.0576696, 3.0562506, -7.5168324, 0.55766946, 7.5062504, -6.516833, 0.55766946, 7.5062504, -1.2168322, 0.55766946, 4.706251, -1.1168327, 0.55766946, 4.856251, -1.7168322, 0.55766946, 7.0562496, -1.9168329, 0.55766946, 7.2562504, -1.5168324, 0.55766946, 4.60625, -1.3168325, 0.55766946, 5.356251, -0.96683216, 0.55766946, 5.456251, -2.5168324, 0.6076694, 7.5062504, -0.71683216, 0.55766946, 5.8062496, -1.6168327, 0.55766946, 6.65625, -1.6168327, 0.55766946, 5.7562504, -1.9168329, 0.55766946, 5.856251, -3.2668328, 1.9576695, 4.5562506, -3.2668328, 1.9576695, 5.206251, -3.0668325, 2.0576694, 5.106251, -0.51683235, 2.5576694, 4.90625, -0.46683216, 2.5576694, 5.2562504, -0.06683254, 2.6076694, 5.15625, -0.16683292, 2.6076694, 4.8062496, -2.7168322, 1.7076695, 6.5062504, -2.8668327, 1.7076695, 6.0562496, -3.1668324, 1.7576694, 5.90625, -3.3168325, 1.8076694, 6.706251, -3.3168325, 1.8076694, 5.706251) +polygons = [PackedInt32Array(3, 2, 0), PackedInt32Array(0, 2, 1), PackedInt32Array(6, 5, 4), PackedInt32Array(9, 8, 7), PackedInt32Array(10, 6, 4), PackedInt32Array(9, 7, 10), PackedInt32Array(4, 11, 10), PackedInt32Array(10, 11, 9), PackedInt32Array(13, 12, 14), PackedInt32Array(14, 12, 15), PackedInt32Array(18, 19, 15), PackedInt32Array(15, 19, 16), PackedInt32Array(16, 19, 17), PackedInt32Array(17, 19, 18), PackedInt32Array(22, 21, 20), PackedInt32Array(14, 15, 23), PackedInt32Array(23, 15, 16), PackedInt32Array(23, 16, 24), PackedInt32Array(17, 18, 20), PackedInt32Array(20, 18, 25), PackedInt32Array(20, 25, 22), PackedInt32Array(28, 30, 29), PackedInt32Array(29, 30, 27), PackedInt32Array(29, 27, 26), PackedInt32Array(33, 32, 31), PackedInt32Array(28, 29, 36), PackedInt32Array(36, 29, 34), PackedInt32Array(34, 29, 26), PackedInt32Array(34, 26, 35), PackedInt32Array(33, 31, 34), PackedInt32Array(34, 31, 37), PackedInt32Array(34, 35, 33), PackedInt32Array(22, 39, 21), PackedInt32Array(21, 39, 38), PackedInt32Array(46, 47, 44), PackedInt32Array(44, 47, 40), PackedInt32Array(40, 47, 41), PackedInt32Array(41, 47, 45), PackedInt32Array(45, 47, 42), PackedInt32Array(42, 47, 43), PackedInt32Array(43, 47, 46), PackedInt32Array(40, 48, 44), PackedInt32Array(51, 50, 49), PackedInt32Array(53, 55, 54), PackedInt32Array(54, 56, 52), PackedInt32Array(52, 51, 49), PackedInt32Array(51, 56, 42), PackedInt32Array(42, 56, 55), PackedInt32Array(55, 56, 54), PackedInt32Array(56, 51, 52), PackedInt32Array(42, 55, 45), PackedInt32Array(45, 55, 41), PackedInt32Array(41, 55, 53), PackedInt32Array(52, 57, 54), PackedInt32Array(58, 54, 59), PackedInt32Array(59, 54, 57), PackedInt32Array(51, 61, 50), PackedInt32Array(50, 61, 60), PackedInt32Array(28, 64, 30), PackedInt32Array(30, 64, 27), PackedInt32Array(27, 64, 62), PackedInt32Array(62, 64, 63), PackedInt32Array(62, 63, 65), PackedInt32Array(65, 63, 66), PackedInt32Array(5, 68, 4), PackedInt32Array(4, 68, 67), PackedInt32Array(70, 69, 71), PackedInt32Array(71, 69, 73), PackedInt32Array(71, 73, 72), PackedInt32Array(75, 74, 76), PackedInt32Array(76, 74, 72), PackedInt32Array(73, 76, 72), PackedInt32Array(78, 77, 79), PackedInt32Array(79, 77, 80), PackedInt32Array(80, 77, 82), PackedInt32Array(80, 82, 81), PackedInt32Array(48, 40, 83), PackedInt32Array(83, 84, 48), PackedInt32Array(48, 84, 85), PackedInt32Array(85, 84, 86), PackedInt32Array(89, 88, 87), PackedInt32Array(87, 90, 89), PackedInt32Array(89, 90, 91), PackedInt32Array(94, 93, 95), PackedInt32Array(95, 93, 92), PackedInt32Array(97, 96, 86), PackedInt32Array(99, 98, 100), PackedInt32Array(100, 98, 101), PackedInt32Array(95, 92, 84), PackedInt32Array(84, 92, 91), PackedInt32Array(84, 91, 86), PackedInt32Array(86, 91, 97), PackedInt32Array(101, 98, 102), PackedInt32Array(102, 98, 103), PackedInt32Array(91, 90, 97), PackedInt32Array(103, 91, 102), PackedInt32Array(102, 91, 92), PackedInt32Array(107, 106, 104), PackedInt32Array(104, 106, 105), PackedInt32Array(93, 94, 108), PackedInt32Array(108, 94, 109), PackedInt32Array(110, 109, 111), PackedInt32Array(111, 109, 58), PackedInt32Array(111, 58, 59), PackedInt32Array(111, 59, 112), PackedInt32Array(109, 110, 108), PackedInt32Array(112, 113, 111), PackedInt32Array(116, 115, 117), PackedInt32Array(117, 115, 114), PackedInt32Array(121, 120, 118), PackedInt32Array(118, 120, 119), PackedInt32Array(124, 123, 122), PackedInt32Array(125, 124, 122), PackedInt32Array(127, 126, 125), PackedInt32Array(125, 122, 127), PackedInt32Array(127, 122, 113), PackedInt32Array(127, 113, 112), PackedInt32Array(129, 128, 24), PackedInt32Array(24, 128, 23), PackedInt32Array(132, 131, 133), PackedInt32Array(133, 131, 130), PackedInt32Array(134, 133, 130), PackedInt32Array(135, 137, 136), PackedInt32Array(139, 141, 140), PackedInt32Array(140, 141, 138), PackedInt32Array(138, 141, 135), PackedInt32Array(135, 141, 137), PackedInt32Array(144, 143, 142), PackedInt32Array(139, 147, 145), PackedInt32Array(145, 147, 142), PackedInt32Array(142, 146, 144), PackedInt32Array(144, 146, 138), PackedInt32Array(138, 146, 140), PackedInt32Array(140, 147, 139), PackedInt32Array(147, 146, 142), PackedInt32Array(146, 147, 140), PackedInt32Array(150, 149, 148), PackedInt32Array(152, 151, 153), PackedInt32Array(153, 151, 154), PackedInt32Array(157, 156, 155), PackedInt32Array(155, 156, 148), PackedInt32Array(148, 156, 150), PackedInt32Array(159, 158, 160), PackedInt32Array(160, 158, 161), PackedInt32Array(161, 158, 162), PackedInt32Array(162, 158, 163), PackedInt32Array(160, 164, 159), PackedInt32Array(165, 160, 166), PackedInt32Array(166, 160, 161), PackedInt32Array(157, 167, 156), PackedInt32Array(156, 167, 162), PackedInt32Array(99, 100, 166), PackedInt32Array(166, 100, 165), PackedInt32Array(168, 161, 167), PackedInt32Array(167, 161, 162), PackedInt32Array(154, 151, 163), PackedInt32Array(163, 151, 162), PackedInt32Array(160, 169, 164), PackedInt32Array(171, 170, 172), PackedInt32Array(172, 170, 173), PackedInt32Array(173, 170, 174), PackedInt32Array(176, 175, 143), PackedInt32Array(143, 175, 142), PackedInt32Array(180, 179, 177), PackedInt32Array(177, 179, 178), PackedInt32Array(182, 181, 183), PackedInt32Array(183, 181, 184), PackedInt32Array(185, 126, 127), PackedInt32Array(163, 158, 186), PackedInt32Array(186, 158, 187), PackedInt32Array(188, 183, 184), PackedInt32Array(189, 188, 184), PackedInt32Array(190, 185, 127), PackedInt32Array(191, 189, 184), PackedInt32Array(194, 193, 192), PackedInt32Array(190, 127, 195), PackedInt32Array(195, 127, 198), PackedInt32Array(195, 198, 196), PackedInt32Array(196, 198, 197), PackedInt32Array(191, 184, 196), PackedInt32Array(196, 184, 186), PackedInt32Array(196, 186, 187), PackedInt32Array(196, 187, 195), PackedInt32Array(192, 197, 194), PackedInt32Array(194, 197, 198), PackedInt32Array(201, 200, 199), PackedInt32Array(204, 206, 205), PackedInt32Array(205, 206, 203), PackedInt32Array(205, 203, 202), PackedInt32Array(209, 208, 207), PackedInt32Array(209, 207, 210), PackedInt32Array(209, 210, 204), PackedInt32Array(205, 213, 204), PackedInt32Array(204, 213, 209), PackedInt32Array(209, 213, 212), PackedInt32Array(212, 202, 211), PackedInt32Array(202, 213, 205), PackedInt32Array(213, 202, 212), PackedInt32Array(214, 136, 215), PackedInt32Array(215, 136, 137), PackedInt32Array(219, 218, 216), PackedInt32Array(216, 218, 217), PackedInt32Array(223, 222, 220), PackedInt32Array(220, 222, 221), PackedInt32Array(225, 224, 209), PackedInt32Array(209, 224, 208), PackedInt32Array(181, 182, 226), PackedInt32Array(226, 182, 227), PackedInt32Array(229, 228, 194), PackedInt32Array(226, 227, 230), PackedInt32Array(230, 227, 231), PackedInt32Array(231, 227, 232), PackedInt32Array(233, 229, 194), PackedInt32Array(234, 193, 235), PackedInt32Array(235, 193, 228), PackedInt32Array(228, 193, 194), PackedInt32Array(232, 234, 231), PackedInt32Array(231, 234, 236), PackedInt32Array(236, 234, 235), PackedInt32Array(235, 237, 236), PackedInt32Array(240, 239, 238), PackedInt32Array(244, 243, 241), PackedInt32Array(241, 243, 242), PackedInt32Array(246, 245, 247), PackedInt32Array(247, 245, 248), PackedInt32Array(248, 249, 247)] geometry_source_geometry_mode = 1 cell_size = 0.05 cell_height = 0.05 @@ -37,9 +36,6 @@ size = Vector3(1.2, 1, 1.3) radius = 0.15 height = 1.0 -[sub_resource type="BoxShape3D" id="BoxShape3D_trtic"] -size = Vector3(0.65, 1, 0.65) - [sub_resource type="Environment" id="Environment_uwrxv"] background_mode = 1 background_color = Color(0.15027824, 1.627421e-05, 0.15027693, 1) @@ -55,20 +51,6 @@ size = Vector3(16, 16, 8) [node name="Game" type="Node3D" unique_id=1358608749] script = ExtResource("1_gee14") -[node name="Sprite2D" type="TextureRect" parent="." unique_id=1459592458] -anchors_preset = 8 -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -offset_left = -4.0 -offset_top = -8.0 -offset_right = 4.0 -offset_bottom = 8.0 -grow_horizontal = 2 -grow_vertical = 2 -texture = ExtResource("2_ir15t") - [node name="Navmesh" type="NavigationRegion3D" parent="." unique_id=1857418222] visible = false navigation_mesh = SubResource("NavigationMesh_kvuet") @@ -287,7 +269,13 @@ material = ExtResource("4_kvuet") [node name="Props" type="Node3D" parent="Map" unique_id=2137952764] [node name="Stalagmite" parent="Map/Props" unique_id=39322424 instance=ExtResource("5_iywne")] -transform = Transform3D(1, 0, 0, 0, 0.8, 0, 0, 0, 1, 4, 0.48141205, 2.5) +transform = Transform3D(1, 0, 0, 0, 0.8, 0, 0, 0, 1, 1, 0.48141205, -2.5) + +[node name="Stalagmite5" parent="Map/Props" unique_id=1945315033 instance=ExtResource("5_iywne")] +transform = Transform3D(0.9998552, 0, -0.017016139, 0, 0.8, 0, 0.017016139, 0, 0.9998552, 4.488328, 0.48141205, -2.5) + +[node name="Stalagmite6" parent="Map/Props" unique_id=2097625970 instance=ExtResource("5_iywne")] +transform = Transform3D(1, 0, 0, 0, 0.8, 0, 0, 0, 1, -1, 0.48141205, -2.5) [node name="Stalagmite4" parent="Map/Props" unique_id=1700522460 instance=ExtResource("5_iywne")] transform = Transform3D(-1, -8.742278e-08, 0, 8.742278e-08, -1, 0, 0, 0, 1, 0, 6.981412, 3.5) @@ -352,41 +340,32 @@ shape = SubResource("CapsuleShape3D_yqjtg") [node name="Floorcast" type="RayCast3D" parent="Player" unique_id=991770843] target_position = Vector3(0, -16, 0) -[node name="Dreamer" type="CharacterBody3D" parent="." unique_id=1925258977] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3, -4.5) -collision_layer = 2 -collision_mask = 2 -script = ExtResource("12_trtic") +[node name="Label3D" type="Label3D" parent="Player" unique_id=119675212] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) +billboard = 2 +no_depth_test = true +text = "test" -[node name="HitCollision" type="Area3D" parent="Dreamer" unique_id=1754593615] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1500001, 0) -collision_layer = 0 +[node name="Dreamer" parent="." unique_id=272925354 instance=ExtResource("13_ca42v")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 3, -4.5) -[node name="Shape" type="CollisionShape3D" parent="Dreamer/HitCollision" unique_id=1642136717] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.5) -shape = SubResource("BoxShape3D_trtic") +[node name="Dreamer2" parent="." unique_id=1482035031 instance=ExtResource("13_ca42v")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 3, -4.5) -[node name="DreamerBody" parent="Dreamer" unique_id=595793987 instance=ExtResource("4_p57ef")] +[node name="Dreamer3" parent="." unique_id=1936797258 instance=ExtResource("13_ca42v")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 3, -4.5) -[node name="Shadow" type="Sprite3D" parent="Dreamer" unique_id=701404522] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2, 0) -modulate = Color(1, 1, 1, 0.5764706) -pixel_size = 0.03 -axis = 1 -texture_filter = 0 -texture = ExtResource("4_lbhrr") +[node name="Dreamer4" parent="." unique_id=1127143563 instance=ExtResource("13_ca42v")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 3, -3.5) -[node name="Collision" type="CollisionShape3D" parent="Dreamer" unique_id=555914177] -shape = SubResource("CapsuleShape3D_yqjtg") +[node name="Dreamer5" parent="." unique_id=1933354822 instance=ExtResource("13_ca42v")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 3, -3.5) -[node name="Floorcast" type="RayCast3D" parent="Dreamer" unique_id=844808342] -target_position = Vector3(0, -16, 0) - -[node name="Navigator" type="NavigationAgent3D" parent="Dreamer" unique_id=1232298712] -path_postprocessing = 2 +[node name="Dreamer6" parent="." unique_id=860097929 instance=ExtResource("13_ca42v")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3, -3.5) [node name="Slime" parent="." unique_id=393738189 instance=ExtResource("6_u5sy4")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 3, -3.81) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 3, -5.81) [node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1956400862] environment = SubResource("Environment_uwrxv") diff --git a/scripts/enemies/dreamer.gd b/scripts/enemies/dreamer.gd index b02515f..b7ab16c 100644 --- a/scripts/enemies/dreamer.gd +++ b/scripts/enemies/dreamer.gd @@ -34,6 +34,10 @@ var state_timer := 0.0 @onready var navigation_agent: NavigationAgent3D = $Navigator +func _on_navigator_velocity_computed(safe_velocity: Vector3) -> void: + velocity = safe_velocity + move_and_slide() + func hit_me(): iframes = 0.5 health -= 10 @@ -68,8 +72,10 @@ func _process(delta: float) -> void: knockback_time -= delta func _physics_process(delta: float) -> void: + var intended_velocity = velocity + if not is_on_floor(): - velocity += get_gravity() * delta + intended_velocity += get_gravity() * delta var viewport_half = (get_viewport().get_visible_rect().size / 2.0) var player_position = Vector2.ZERO #camera.unproject_position(global_transform.origin) @@ -109,7 +115,7 @@ func _physics_process(delta: float) -> void: $DreamerBody/Body/ArmPivot.rotation.z = 0 if false: - velocity.y = JUMP_VELOCITY + intended_velocity.y = JUMP_VELOCITY $DreamerBody/Animator.set("parameters/jump/request", AnimationNodeOneShot.ONE_SHOT_REQUEST_FIRE) var direction = Vector3.ZERO @@ -179,17 +185,26 @@ func _physics_process(delta: float) -> void: face_left = true if direction and (knockback_time <= 0): - velocity.x = direction.x * SPEED - velocity.z = direction.z * SPEED + intended_velocity.x = direction.x * SPEED + intended_velocity.z = direction.z * SPEED $DreamerBody/Animator.set("parameters/walk/blend_amount", abs(direction.length())) + + navigation_agent.avoidance_enabled = true + navigation_agent.set_velocity(intended_velocity) else: - velocity.x = move_toward(velocity.x, 0, delta * 4) - velocity.z = move_toward(velocity.z, 0, delta * 4) + intended_velocity.x = move_toward(intended_velocity.x, 0, delta * 4) + intended_velocity.z = move_toward(intended_velocity.z, 0, delta * 4) $DreamerBody/Animator.set("parameters/walk/blend_amount", 0) + navigation_agent.avoidance_enabled = false + + velocity = intended_velocity + move_and_slide() + + if direction and is_on_floor(): walk_animation_time += delta * 25 @@ -212,9 +227,6 @@ func _physics_process(delta: float) -> void: else: $DreamerBody/Animator.set("parameters/fall/blend_amount", 0) $DreamerBody/Animator.set("parameters/leap/blend_amount", 1) - - move_and_slide() - $Shadow.global_position.y = $Floorcast.get_collision_point().y + 0.01 diff --git a/scripts/player.gd b/scripts/player.gd index 99eebda..7c06b95 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -74,7 +74,7 @@ func _process(delta: float) -> void: else: $DreamerBody/Animator.set("parameters/hit/blend_amount", 0.0) -func _physics_process(delta: float) -> void: +#func _physics_process(delta: float) -> void: $DreamerBody.look_at(game.get_node("PlayerCamera").global_position) $DreamerBody.rotation.x = 0 face_rotation = $DreamerBody.rotation.y @@ -215,7 +215,7 @@ func _physics_process(delta: float) -> void: var knockback_pos = global_position knockback_pos.y = 0 - var knockback_body_pos = body.global_position + var knockback_body_pos = $HitCollision/Shape.global_position knockback_body_pos.y = 0 body.position.y += 0.2 @@ -277,3 +277,5 @@ func _physics_process(delta: float) -> void: $Shadow.global_position.y = $Floorcast.get_collision_point().y + 0.01 + $Label3D.text = str(velocity.length()) + diff --git a/scripts/player_camera.gd b/scripts/player_camera.gd index 2fd6193..f6ea8f4 100644 --- a/scripts/player_camera.gd +++ b/scripts/player_camera.gd @@ -9,8 +9,9 @@ func _ready() -> void: pass func _process(delta: float) -> void: - var goal_position = player.get_node("Collision").global_position + offset - global_position += (goal_position - global_position) / (500 * delta) + var goal_position = player.get_node("Collision").global_position + offset + + global_position = lerp(global_position, goal_position, min(delta * 4, 1.0)) for n in camera_zones.get_children(): if player in n.get_overlapping_bodies():