diff --git a/project.godot b/project.godot index 3575650..6d60108 100644 --- a/project.godot +++ b/project.godot @@ -89,6 +89,12 @@ limbo_console_search_history={ ] } +[layer_names] + +3d_physics/layer_1="player" +3d_physics/layer_2="enemies" +3d_physics/layer_9="camera" + [navigation] 3d/default_cell_size=0.05 diff --git a/scenes/game.tscn b/scenes/game.tscn index 3305f62..5871cc2 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -4,6 +4,7 @@ [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"] @@ -12,8 +13,9 @@ [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="PackedScene" uid="uid://b2w6hcvr8mimm" path="res://scenes/effects/damage_text.tscn" id="11_kvpfn"] [ext_resource type="Script" uid="uid://vi18m3j6f6fa" path="res://scripts/enemies/dreamer.gd" id="12_trtic"] +[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) @@ -24,6 +26,9 @@ cell_height = 0.05 [sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_yqjtg"] +[sub_resource type="SphereShape3D" id="SphereShape3D_kvuet"] +radius = 0.001 + [sub_resource type="BoxShape3D" id="BoxShape3D_0tnpc"] size = Vector3(1.2, 1, 1.3) @@ -39,10 +44,30 @@ background_mode = 1 background_color = Color(0.21272367, 0.00026760699, 0.30778188, 1) tonemap_mode = 2 volumetric_fog_enabled = true +adjustment_enabled = true +adjustment_brightness = 1.25 +adjustment_contrast = 1.1 + +[sub_resource type="BoxShape3D" id="BoxShape3D_kvuet"] +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") @@ -76,6 +101,15 @@ collision_mask = 255 size = Vector3(2, 7, 16) material = ExtResource("3_dinhu") +[node name="CSGBox3D10" type="CSGBox3D" parent="Map/CSG" unique_id=850781226] +transform = Transform3D(0.8660254, 0.5, 0, -0.5, 0.8660254, 0, 0, 0, 1, -4.125, 5.5155444, 0) +layers = 1023 +use_collision = true +collision_layer = 255 +collision_mask = 255 +size = Vector3(2, 3.5, 16) +material = ExtResource("3_dinhu") + [node name="CSGBox3D6" type="CSGBox3D" parent="Map/CSG" unique_id=647905404] transform = Transform3D(0.85165083, -0.42261833, 0.30997553, 0.39713126, 0.90630776, 0.14454395, -0.34202015, 0, 0.93969274, -3.2622721, 0.7556524, 4.6872506) layers = 1023 @@ -133,7 +167,7 @@ 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, 1, 0, 0, 0, 1, 4, 0.48141205, 2.5) +transform = Transform3D(1, 0, 0, 0, 0.8, 0, 0, 0, 1, 4, 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) @@ -145,10 +179,10 @@ transform = Transform3D(0.81915206, 0, -0.57357645, 0, 1, 0, 0.57357645, 0, 0.81 transform = Transform3D(0.50000006, 0, -0.86602557, 0, 0.9, 0, 0.86602557, 0, 0.50000006, -2, 0.48141205, 1) [node name="blockbench_export" parent="Map/Props" unique_id=1509742770 instance=ExtResource("9_vtaks")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.4827318, 0.4921612, -1.048477) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.9827318, 0.4921612, -0.54847705) [node name="blockbench_export2" parent="Map/Props" unique_id=992880863 instance=ExtResource("10_kvpfn")] -transform = Transform3D(0.34202015, 0, -0.9396926, 0, 1, 0, 0.9396926, 0, 0.34202015, 0.2356708, 0.49367946, 4.5695834) +transform = Transform3D(0.34202015, 0, -0.9396926, 0, 1, 0, 0.9396926, 0, 0.34202015, -0.2643292, 0.49367946, 5.0695834) [node name="PlayerCamera" type="Camera3D" parent="." unique_id=1101523944] transform = Transform3D(0.7071067, -0.40557978, 0.5792279, 0, 0.819152, 0.5735764, -0.7071067, -0.40557978, 0.5792279, 4, 6.5, 4) @@ -156,6 +190,13 @@ attributes = SubResource("CameraAttributesPractical_yqjtg") fov = 65.0 script = ExtResource("1_lnu2h") +[node name="Area" type="Area3D" parent="PlayerCamera" unique_id=400816746] +collision_layer = 256 +collision_mask = 0 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="PlayerCamera/Area" unique_id=1525913675] +shape = SubResource("SphereShape3D_kvuet") + [node name="Player" type="CharacterBody3D" parent="." unique_id=1201448850] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3, 0) script = ExtResource("1_yqjtg") @@ -217,7 +258,6 @@ target_position = Vector3(0, -16, 0) [node name="Navigator" type="NavigationAgent3D" parent="Dreamer" unique_id=1232298712] path_postprocessing = 2 -debug_enabled = true [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) @@ -225,6 +265,34 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 3, -3.81) [node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1956400862] environment = SubResource("Environment_uwrxv") -[node name="DamageText" parent="." unique_id=670799148 instance=ExtResource("11_kvpfn")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.23, 0) -gravity_scale = 2.5 +[node name="CameraZones" type="Node3D" parent="." unique_id=1225967945] + +[node name="CameraZone2" type="Area3D" parent="CameraZones" unique_id=1501599928] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 4) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="CameraZones/CameraZone2" unique_id=693968382] +shape = SubResource("BoxShape3D_kvuet") + +[node name="Offset" type="Node3D" parent="CameraZones/CameraZone2" unique_id=1432752210] + +[node name="Camera" type="Sprite3D" parent="CameraZones/CameraZone2/Offset" unique_id=1992696506] +transform = Transform3D(-4.3711385e-08, -0.7071067, 0.70710677, 0, 0.7071067, 0.70710677, -0.99999994, 3.0908616e-08, -3.090862e-08, 4, 4, 0) +pixel_size = 0.05 +double_sided = false +texture = ExtResource("14_trtic") +script = ExtResource("16_ca42v") + +[node name="CameraZone" type="Area3D" parent="CameraZones" unique_id=1280290524] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -4) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="CameraZones/CameraZone" unique_id=1757431784] +shape = SubResource("BoxShape3D_kvuet") + +[node name="Offset" type="Node3D" parent="CameraZones/CameraZone" unique_id=1829870767] + +[node name="Camera" type="Sprite3D" parent="CameraZones/CameraZone/Offset" unique_id=1388726824] +transform = Transform3D(0.7071067, -0.40557975, 0.5792279, 0, 0.81915194, 0.5735764, -0.7071067, -0.40557975, 0.5792279, 4, 4, 4) +pixel_size = 0.05 +double_sided = false +texture = ExtResource("14_trtic") +script = ExtResource("16_ca42v") diff --git a/scripts/enemies/dreamer.gd b/scripts/enemies/dreamer.gd index ebe65bf..a7df36e 100644 --- a/scripts/enemies/dreamer.gd +++ b/scripts/enemies/dreamer.gd @@ -4,7 +4,7 @@ const SPEED = 2.5 const JUMP_VELOCITY = 3.5 var walk_animation_time = 0 -var face_rotation = null +var face_rotation = 0 var face_left = false var combatable = true @@ -51,11 +51,12 @@ func on_knockback(hitter: Node3D = null) -> void: state_timer = 0.5 func _ready() -> void: - $DreamerBody.rotation.x = 0 - face_rotation = player.face_rotation $DreamerBody/Animator.set("parameters/hold_weapon/blend_amount", 1.0) func _process(delta: float) -> void: + $DreamerBody.rotation.x = 0 + face_rotation = player.face_rotation + if iframes > 0: iframes -= delta $DreamerBody/Body.modulate.a = 0.5 diff --git a/scripts/enemies/slime.gd b/scripts/enemies/slime.gd index afc570f..f9b23af 100644 --- a/scripts/enemies/slime.gd +++ b/scripts/enemies/slime.gd @@ -3,7 +3,7 @@ extends CharacterBody3D const SPEED = 2.5 const JUMP_VELOCITY = 4.5 -var face_rotation = null +var face_rotation = 0 var face_left = false var health = 35 @@ -33,13 +33,12 @@ func on_knockback() -> void: $Body/Animator.play("leap") func _ready() -> void: - $Body.look_at(game.get_node("PlayerCamera").global_position) - $Body.rotation.x = 0 - face_rotation = $Body.rotation.y $Body/Animator.play("idle") func _physics_process(delta: float) -> void: + face_rotation = player.get_node("DreamerBody").global_rotation.y + if (health <= 0) and (state != STATE_DEATH): state = STATE_DEATH state_timer = 0.75 diff --git a/scripts/hide_node.gd b/scripts/hide_node.gd new file mode 100644 index 0000000..f88fb92 --- /dev/null +++ b/scripts/hide_node.gd @@ -0,0 +1,4 @@ +extends Node3D + +func _ready() -> void: + visible = false diff --git a/scripts/hide_node.gd.uid b/scripts/hide_node.gd.uid new file mode 100644 index 0000000..7009db0 --- /dev/null +++ b/scripts/hide_node.gd.uid @@ -0,0 +1 @@ +uid://btuscff4168hb diff --git a/scripts/player.gd b/scripts/player.gd index bfe4eae..8b0676a 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -4,7 +4,7 @@ const SPEED = 3.5 const JUMP_VELOCITY = 3.5 var walk_animation_time = 0 -var face_rotation = null +var face_rotation = 0 var face_left = false var combatable = true @@ -45,13 +45,10 @@ func on_hit(hitter: Node3D = null) -> void: velocity.y = 0 func _ready() -> void: - $DreamerBody.look_at(game.get_node("PlayerCamera").global_position) - $DreamerBody.rotation.x = 0 - face_rotation = $DreamerBody.rotation.y - LimboConsole.register_command(hit_me) func _process(delta: float) -> void: + if iframes > 0: iframes -= delta $DreamerBody/Body.modulate.a = 0.5 @@ -62,6 +59,11 @@ func _process(delta: float) -> void: knockback_time -= delta func _physics_process(delta: float) -> void: + $DreamerBody.look_at(game.get_node("PlayerCamera").global_position) + $DreamerBody.rotation.x = 0 + face_rotation = $DreamerBody.rotation.y + if not face_rotation: face_rotation = 0 + if not is_on_floor(): velocity += get_gravity() * delta diff --git a/scripts/player_camera.gd b/scripts/player_camera.gd index f43da42..2fd6193 100644 --- a/scripts/player_camera.gd +++ b/scripts/player_camera.gd @@ -1,11 +1,18 @@ extends Camera3D -@onready var player = get_parent().get_node("Player") +@onready var game = get_parent() +@onready var camera_zones = game.get_node("CameraZones") +@onready var player = game.get_node("Player") @onready var offset = position - player.position func _ready() -> void: pass func _process(delta: float) -> void: - var goal_position = player.global_position + offset + var goal_position = player.get_node("Collision").global_position + offset global_position += (goal_position - global_position) / (500 * delta) + + for n in camera_zones.get_children(): + if player in n.get_overlapping_bodies(): + offset = n.get_node("Offset/Camera").position + rotation = n.get_node("Offset/Camera").rotation