From 107c7622d5f030fa532d5829cafbb332acd97ab9 Mon Sep 17 00:00:00 2001 From: Minimata Date: Mon, 16 Jun 2025 16:13:29 +0200 Subject: [PATCH] gd: game feel improvement, dash limit, improved jump while aiming for dash --- addons/guide/debugger/guide_debugger.tscn | 2 +- maps/GYMs/metrics.tscn | 258 +++++++++++++++++- maps/city.tscn | 236 ++++++++++++++-- player_controller/PlayerController.tscn | 47 +++- player_controller/Scripts/Gravity.cs | 18 +- player_controller/Scripts/PlayerController.cs | 95 +++++-- systems/mantle/mantle_system.tscn | 3 +- systems/move/MoveSystem.cs | 111 +++++--- 8 files changed, 669 insertions(+), 101 deletions(-) diff --git a/addons/guide/debugger/guide_debugger.tscn b/addons/guide/debugger/guide_debugger.tscn index 0e7caf4..50006d1 100644 --- a/addons/guide/debugger/guide_debugger.tscn +++ b/addons/guide/debugger/guide_debugger.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://dkr80d2pi0d41"] -[ext_resource type="Script" path="res://addons/guide/debugger/guide_debugger.gd" id="1_ckdvj"] +[ext_resource type="Script" uid="uid://cqfnsis3hhdrv" path="res://addons/guide/debugger/guide_debugger.gd" id="1_ckdvj"] [node name="GuideDebugger" type="MarginContainer"] anchors_preset = 15 diff --git a/maps/GYMs/metrics.tscn b/maps/GYMs/metrics.tscn index 2f80f24..137d12f 100644 --- a/maps/GYMs/metrics.tscn +++ b/maps/GYMs/metrics.tscn @@ -29,7 +29,7 @@ glow_enabled = true [node name="Main" type="Node3D"] [node name="Player" parent="." instance=ExtResource("1_1s2y7")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.7981, 1.6118, 39.3006) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -10, 6, -31) [node name="WorldEnvironment" type="WorldEnvironment" parent="."] environment = SubResource("Environment_1bvp3") @@ -53,3 +53,259 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.09619, -0.472656, -46.3293 use_collision = true size = Vector3(100, 1, 190.741) material = ExtResource("3_vvhq3") + +[node name="RunningTrack" type="CSGCombiner3D" parent="Greybox"] + +[node name="CSGBox3D2" type="CSGBox3D" parent="Greybox/RunningTrack"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) +use_collision = true +size = Vector3(0.2, 2, 0.2) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D3" type="CSGBox3D" parent="Greybox/RunningTrack"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -10) +use_collision = true +size = Vector3(0.2, 2, 0.2) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D4" type="CSGBox3D" parent="Greybox/RunningTrack"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -20) +use_collision = true +size = Vector3(0.2, 2, 0.2) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D5" type="CSGBox3D" parent="Greybox/RunningTrack"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -30) +use_collision = true +size = Vector3(0.2, 2, 0.2) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D6" type="CSGBox3D" parent="Greybox/RunningTrack"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -40) +use_collision = true +size = Vector3(0.2, 2, 0.2) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D7" type="CSGBox3D" parent="Greybox/RunningTrack"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -50) +use_collision = true +size = Vector3(0.2, 2, 0.2) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D8" type="CSGBox3D" parent="Greybox/RunningTrack"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 1, 0) +use_collision = true +size = Vector3(0.2, 2, 0.2) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D9" type="CSGBox3D" parent="Greybox/RunningTrack"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 1, -10) +use_collision = true +size = Vector3(0.2, 2, 0.2) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D10" type="CSGBox3D" parent="Greybox/RunningTrack"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 1, -20) +use_collision = true +size = Vector3(0.2, 2, 0.2) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D11" type="CSGBox3D" parent="Greybox/RunningTrack"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 1, -30) +use_collision = true +size = Vector3(0.2, 2, 0.2) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D12" type="CSGBox3D" parent="Greybox/RunningTrack"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 1, -40) +use_collision = true +size = Vector3(0.2, 2, 0.2) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D13" type="CSGBox3D" parent="Greybox/RunningTrack"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 1, -50) +use_collision = true +size = Vector3(0.2, 2, 0.2) +material = ExtResource("3_vvhq3") + +[node name="Label3D" type="Label3D" parent="Greybox/RunningTrack"] +transform = Transform3D(5, 0, 0, 0, -2.18557e-07, 5, 0, -5, -2.18557e-07, 1, 0.1, -9.5) +text = "10m" + +[node name="Label3D2" type="Label3D" parent="Greybox/RunningTrack"] +transform = Transform3D(5, 0, 0, 0, -2.18557e-07, 5, 0, -5, -2.18557e-07, 1, 0.1, -19.5) +text = "20m" + +[node name="Label3D3" type="Label3D" parent="Greybox/RunningTrack"] +transform = Transform3D(5, 0, 0, 0, -2.18557e-07, 5, 0, -5, -2.18557e-07, 1, 0.1, -29.5) +text = "30m" + +[node name="Label3D4" type="Label3D" parent="Greybox/RunningTrack"] +transform = Transform3D(5, 0, 0, 0, -2.18557e-07, 5, 0, -5, -2.18557e-07, 1, 0.1, -39.5) +text = "40m" + +[node name="Label3D5" type="Label3D" parent="Greybox/RunningTrack"] +transform = Transform3D(5, 0, 0, 0, -2.18557e-07, 5, 0, -5, -2.18557e-07, 1, 0.1, -49) +text = "50m" + +[node name="JumpHeights" type="CSGCombiner3D" parent="Greybox"] + +[node name="Label3D6" type="Label3D" parent="Greybox/JumpHeights"] +transform = Transform3D(-2.18557e-07, -5, -2.18557e-07, 0, -2.18557e-07, 5, -5, 2.18557e-07, 9.55343e-15, -7, 0.1, -1.5) +text = "0.5m" + +[node name="Label3D7" type="Label3D" parent="Greybox/JumpHeights"] +transform = Transform3D(-2.18557e-07, -5, -2.18557e-07, 0, -2.18557e-07, 5, -5, 2.18557e-07, 9.55343e-15, -7, 0.1, -6.5) +text = "1m" + +[node name="Label3D8" type="Label3D" parent="Greybox/JumpHeights"] +transform = Transform3D(-2.18557e-07, -5, -2.18557e-07, 0, -2.18557e-07, 5, -5, 2.18557e-07, 9.55343e-15, -7, 0.1, -11.5) +text = "1.5m" + +[node name="Label3D9" type="Label3D" parent="Greybox/JumpHeights"] +transform = Transform3D(-2.18557e-07, -5, -2.18557e-07, 0, -2.18557e-07, 5, -5, 2.18557e-07, 9.55343e-15, -7, 0.1, -16.5) +text = "2m" + +[node name="Label3D10" type="Label3D" parent="Greybox/JumpHeights"] +transform = Transform3D(-2.18557e-07, -5, -2.18557e-07, 0, -2.18557e-07, 5, -5, 2.18557e-07, 9.55343e-15, -7, 0.1, -21.5) +text = "3m" + +[node name="Label3D11" type="Label3D" parent="Greybox/JumpHeights"] +transform = Transform3D(-2.18557e-07, -5, -2.18557e-07, 0, -2.18557e-07, 5, -5, 2.18557e-07, 9.55343e-15, -7, 0.1, -26.5) +text = "4m" + +[node name="Label3D12" type="Label3D" parent="Greybox/JumpHeights"] +transform = Transform3D(-2.18557e-07, -5, -2.18557e-07, 0, -2.18557e-07, 5, -5, 2.18557e-07, 9.55343e-15, -7, 0.1, -31.5) +text = "5m" + +[node name="Label3D13" type="Label3D" parent="Greybox/JumpHeights"] +transform = Transform3D(-2.18557e-07, -5, -2.18557e-07, 0, -2.18557e-07, 5, -5, 2.18557e-07, 9.55343e-15, -7, 0.1, -36.5) +text = "6m" + +[node name="Label3D14" type="Label3D" parent="Greybox/JumpHeights"] +transform = Transform3D(-2.18557e-07, -5, -2.18557e-07, 0, -2.18557e-07, 5, -5, 2.18557e-07, 9.55343e-15, -7, 0.1, -41.5) +text = "7m" + +[node name="Label3D15" type="Label3D" parent="Greybox/JumpHeights"] +transform = Transform3D(-2.18557e-07, -5, -2.18557e-07, 0, -2.18557e-07, 5, -5, 2.18557e-07, 9.55343e-15, -7, 0.1, -46.5) +text = "8m" + +[node name="Label3D16" type="Label3D" parent="Greybox/JumpHeights"] +transform = Transform3D(-2.18557e-07, -5, -2.18557e-07, 0, -2.18557e-07, 5, -5, 2.18557e-07, 9.55343e-15, -7, 0.1, -51.5) +text = "9m" + +[node name="Label3D17" type="Label3D" parent="Greybox/JumpHeights"] +transform = Transform3D(-2.18557e-07, -5, -2.18557e-07, 0, -2.18557e-07, 5, -5, 2.18557e-07, 9.55343e-15, -7, 0.1, -56.5) +text = "10m" + +[node name="Label3D18" type="Label3D" parent="Greybox/JumpHeights"] +transform = Transform3D(-2.18557e-07, -5, -2.18557e-07, 0, -2.18557e-07, 5, -5, 2.18557e-07, 9.55343e-15, -7, 0.1, -61.5) +text = "12.5m" + +[node name="Label3D19" type="Label3D" parent="Greybox/JumpHeights"] +transform = Transform3D(-2.18557e-07, -5, -2.18557e-07, 0, -2.18557e-07, 5, -5, 2.18557e-07, 9.55343e-15, -7, 0.1, -66.5) +text = "15m" + +[node name="Label3D20" type="Label3D" parent="Greybox/JumpHeights"] +transform = Transform3D(-2.18557e-07, -5, -2.18557e-07, 0, -2.18557e-07, 5, -5, 2.18557e-07, 9.55343e-15, -7, 0.1, -71.5) +text = "17.5m" + +[node name="Label3D21" type="Label3D" parent="Greybox/JumpHeights"] +transform = Transform3D(-2.18557e-07, -5, -2.18557e-07, 0, -2.18557e-07, 5, -5, 2.18557e-07, 9.55343e-15, -7, 0.1, -76.5) +text = "20m" + +[node name="CSGBox3D14" type="CSGBox3D" parent="Greybox/JumpHeights"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -10.5, 0.25, -1.5) +use_collision = true +size = Vector3(5, 0.5, 5) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D15" type="CSGBox3D" parent="Greybox/JumpHeights"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -10.5, 0.5, -6.5) +use_collision = true +size = Vector3(5, 1, 5) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D16" type="CSGBox3D" parent="Greybox/JumpHeights"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -10.5, 0.75, -11.5) +use_collision = true +size = Vector3(5, 1.5, 5) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D17" type="CSGBox3D" parent="Greybox/JumpHeights"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -10.5, 1, -16.5) +use_collision = true +size = Vector3(5, 2, 5) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D18" type="CSGBox3D" parent="Greybox/JumpHeights"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -10.5, 1.5, -21.5) +use_collision = true +size = Vector3(5, 3, 5) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D19" type="CSGBox3D" parent="Greybox/JumpHeights"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -10.5, 2, -26.5) +use_collision = true +size = Vector3(5, 4, 5) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D20" type="CSGBox3D" parent="Greybox/JumpHeights"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -10.5, 2.5, -31.5) +use_collision = true +size = Vector3(5, 5, 5) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D21" type="CSGBox3D" parent="Greybox/JumpHeights"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -10.5, 3, -36.5) +use_collision = true +size = Vector3(5, 6, 5) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D22" type="CSGBox3D" parent="Greybox/JumpHeights"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -10.5, 3.5, -41.5) +use_collision = true +size = Vector3(5, 7, 5) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D23" type="CSGBox3D" parent="Greybox/JumpHeights"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -10.5, 4, -46.5) +use_collision = true +size = Vector3(5, 8, 5) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D24" type="CSGBox3D" parent="Greybox/JumpHeights"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -10.5, 4.5, -51.5) +use_collision = true +size = Vector3(5, 9, 5) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D25" type="CSGBox3D" parent="Greybox/JumpHeights"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -10.5, 5, -56.5) +use_collision = true +size = Vector3(5, 10, 5) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D26" type="CSGBox3D" parent="Greybox/JumpHeights"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -10.5, 6.25, -61.5) +use_collision = true +size = Vector3(5, 12.5, 5) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D27" type="CSGBox3D" parent="Greybox/JumpHeights"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -10.5, 7.5, -66.5) +use_collision = true +size = Vector3(5, 15, 5) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D28" type="CSGBox3D" parent="Greybox/JumpHeights"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -10.5, 8.75, -71.5) +use_collision = true +size = Vector3(5, 17.5, 5) +material = ExtResource("3_vvhq3") + +[node name="CSGBox3D29" type="CSGBox3D" parent="Greybox/JumpHeights"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -10.5, 10, -76.5) +use_collision = true +size = Vector3(5, 20, 5) +material = ExtResource("3_vvhq3") diff --git a/maps/city.tscn b/maps/city.tscn index 9321344..99b5ec8 100644 --- a/maps/city.tscn +++ b/maps/city.tscn @@ -76,6 +76,24 @@ use_collision = true size = Vector3(0.5, 1, 16) material = ExtResource("3_cieeo") +[node name="CSGBox3D11" type="CSGBox3D" parent="Greybox/GuardTower"] +transform = Transform3D(-0.0871559, 0, -0.996195, 0, 1, 0, 0.996195, 0, -0.0871559, 29.4115, 40.5, -46.6885) +use_collision = true +size = Vector3(0.5, 1, 11.0214) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D12" type="CSGBox3D" parent="Greybox/GuardTower"] +transform = Transform3D(-0.996195, 0, 0.0871559, 0, 1, 0, -0.0871559, 0, -0.996195, 34.1402, 40.5, -40.499) +use_collision = true +size = Vector3(0.5, 1, 11.0214) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D13" type="CSGBox3D" parent="Greybox/GuardTower"] +transform = Transform3D(-0.996195, 0, 0.0871559, 0, 1, 0, -0.0871559, 0, -0.996195, 23.7052, 40.5, -41.7067) +use_collision = true +size = Vector3(0.5, 1, 10.52) +material = ExtResource("3_cieeo") + [node name="CSGBox3D9" type="CSGBox3D" parent="Greybox/GuardTower"] transform = Transform3D(-1, 0, 8.9407e-08, 0, 1, 0, -8.9407e-08, 0, -1, 10.5, 92, 0) use_collision = true @@ -103,6 +121,148 @@ transform = Transform3D(0.707107, 0, -0.707107, 0, 1, 0, 0.707107, 0, 0.707107, [node name="SmallSquareTower4" parent="Greybox/GuardTower" instance=ExtResource("5_ruo5i")] transform = Transform3D(-0.707107, 0, -0.707107, 0, 1, 0, 0.707107, 0, -0.707107, 10.5, 91.5, -10.5) +[node name="HighWageResidentialBulk1" type="CSGCombiner3D" parent="Greybox"] + +[node name="CSGBox3D12" type="CSGBox3D" parent="Greybox/HighWageResidentialBulk1"] +transform = Transform3D(-0.642788, 0, -0.766045, 0, 1, 0, 0.766045, 0, -0.642788, 122.539, 6.25, -7.09329) +use_collision = true +size = Vector3(66.5, 13.5, 32) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D13" type="CSGBox3D" parent="Greybox/HighWageResidentialBulk1"] +transform = Transform3D(-0.0871557, 0, -0.996195, 0, 1, 0, 0.996195, 0, -0.0871557, 145.089, 6.25, -50.712) +use_collision = true +size = Vector3(59, 13.5, 36.5) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D16" type="CSGBox3D" parent="Greybox/HighWageResidentialBulk1"] +transform = Transform3D(0.173648, 0, -0.984808, 0, 1, 0, 0.984808, 0, 0.173648, 126.82, 6.25, -45.9715) +use_collision = true +size = Vector3(13.5, 13.5, 4.5) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D17" type="CSGBox3D" parent="Greybox/HighWageResidentialBulk1"] +transform = Transform3D(0.173648, 0, -0.984808, 0, 1, 0, 0.984808, 0, 0.173648, 112.63, 6.25, -60.2239) +use_collision = true +size = Vector3(17.5, 13.5, 20.5) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D18" type="CSGBox3D" parent="Greybox/HighWageResidentialBulk1"] +transform = Transform3D(0.173648, 0, -0.984808, 0, 1, 0, 0.984808, 0, 0.173648, 117.839, 6.25, -26.3639) +use_collision = true +size = Vector3(23, 13.5, 22) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D15" type="CSGBox3D" parent="Greybox/HighWageResidentialBulk1"] +transform = Transform3D(0.173648, -0.492404, -0.852869, 0, 0.866025, -0.5, 0.984808, 0.0868242, 0.150384, 111.947, -2.15266, -43.9817) +use_collision = true +size = Vector3(14, 13.5, 37) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D14" type="CSGBox3D" parent="Greybox/HighWageResidentialBulk1"] +transform = Transform3D(0.819153, 0, -0.573577, 0, 1, 0, 0.573577, 0, 0.819153, 135.63, 6.25, -75.0023) +use_collision = true +size = Vector3(45, 13.5, 51.5) +material = ExtResource("3_cieeo") + +[node name="Castle" type="CSGCombiner3D" parent="Greybox"] + +[node name="CSGBox3D19" type="CSGBox3D" parent="Greybox/Castle"] +transform = Transform3D(0.939694, -0.17101, -0.296198, -1.29048e-08, 0.866026, -0.5, 0.34202, 0.469847, 0.813799, 109.798, 0.347346, -137.485) +use_collision = true +size = Vector3(32.5, 13.5, 47) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D20" type="CSGBox3D" parent="Greybox/Castle"] +transform = Transform3D(0.766045, -0.321394, -0.556671, -2.69073e-08, 0.866026, -0.5, 0.642788, 0.383023, 0.663415, 129.363, 19.5973, -166.313) +use_collision = true +size = Vector3(38, 13.5, 50) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D21" type="CSGBox3D" parent="Greybox/Castle"] +transform = Transform3D(0.342021, -0.469847, -0.813799, -2.69073e-08, 0.866026, -0.5, 0.939694, 0.17101, 0.296199, 161.564, 42.8473, -187.035) +use_collision = true +size = Vector3(36, 13.5, 61) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D22" type="CSGBox3D" parent="Greybox/Castle"] +transform = Transform3D(-0.707108, -0.353554, -0.612374, -4.09099e-08, 0.866026, -0.5, 0.707108, -0.353554, -0.612373, 185.313, 57.5973, -190.231) +use_collision = true +size = Vector3(25.5, 13.5, 33) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D23" type="CSGBox3D" parent="Greybox/Castle"] +transform = Transform3D(0.707107, 0, -0.707107, 0, 1, 0, 0.707107, 0, 0.707107, 230.383, 73.25, -153.491) +use_collision = true +size = Vector3(95, 13.5, 138.5) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D31" type="CSGBox3D" parent="Greybox/Castle"] +transform = Transform3D(0.766045, 0, -0.642788, 0, 1, 0, 0.642788, 0, 0.766045, 162.404, 73.25, -122.54) +use_collision = true +size = Vector3(65.5, 13.5, 61.5) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D33" type="CSGBox3D" parent="Greybox/Castle"] +transform = Transform3D(0.866026, 0, -0.5, 0, 1, 0, 0.5, 0, 0.866026, 179.593, 73.25, -89.1927) +use_collision = true +size = Vector3(24.5, 13.5, 30) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D34" type="CSGBox3D" parent="Greybox/Castle"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 196.117, 73.25, -87.4249) +use_collision = true +size = Vector3(36, 13.5, 30) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D32" type="CSGBox3D" parent="Greybox/Castle"] +transform = Transform3D(0.906309, 0, -0.422619, 0, 1, 0, 0.422619, 0, 0.906309, 140.804, 73.25, -102.907) +use_collision = true +size = Vector3(58, 13.5, 15) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D24" type="CSGBox3D" parent="Greybox/Castle"] +transform = Transform3D(0.707107, 0, -0.707107, 0, 1, 0, 0.707107, 0, 0.707107, 274.4, 73.25, -222.257) +use_collision = true +size = Vector3(90, 13.5, 21) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D25" type="CSGBox3D" parent="Greybox/Castle"] +transform = Transform3D(0.707107, 0, -0.707107, 0, 1, 0, 0.707107, 0, 0.707107, 279.703, 73.25, -244.178) +use_collision = true +size = Vector3(27.5, 13.5, 21.5) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D26" type="CSGBox3D" parent="Greybox/Castle"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 263.44, 73.25, -251.249) +use_collision = true +size = Vector3(27.5, 13.5, 21.5) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D27" type="CSGBox3D" parent="Greybox/Castle"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 282.886, 73.25, -227.303) +use_collision = true +size = Vector3(27.5, 13.5, 30.5) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D28" type="CSGBox3D" parent="Greybox/Castle"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 249.298, 73.25, -231.9) +use_collision = true +size = Vector3(27.5, 13.5, 30.5) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D30" type="CSGBox3D" parent="Greybox/Castle"] +transform = Transform3D(0.984809, 0, 0.173648, 0, 1, 0, -0.173648, 0, 0.984809, 172.577, 73.25, -154.471) +use_collision = true +size = Vector3(27.5, 13.5, 30.5) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D29" type="CSGBox3D" parent="Greybox/Castle"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 299.503, 73.25, -183.109) +use_collision = true +size = Vector3(27.5, 13.5, 30.5) +material = ExtResource("3_cieeo") + [node name="CSGBox3D11" type="CSGBox3D" parent="Greybox"] transform = Transform3D(-0.707107, 0, -0.707107, 0, 1, 0, 0.707107, 0, -0.707107, 149.932, -1, -129.284) use_collision = true @@ -148,9 +308,15 @@ size = Vector3(7.98438, 2.5, 7.15942) material = ExtResource("3_cieeo") [node name="CSGBox3D86" type="CSGBox3D" parent="Greybox/LowWageResidentialBulk1"] -transform = Transform3D(0.98478, 0.0449895, 0.167903, 5.00964e-08, 0.965926, -0.258819, -0.173826, 0.25488, 0.951223, 43.4774, 38.7394, -69.6007) +transform = Transform3D(0.98478, 0.0449895, 0.167903, 5.00964e-08, 0.965926, -0.258819, -0.173826, 0.25488, 0.951223, 39.256, 36.2486, -67.5533) use_collision = true -size = Vector3(7.98438, 2.5, 7.15942) +size = Vector3(17, 2.5, 3.36719) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D87" type="CSGBox3D" parent="Greybox/LowWageResidentialBulk1"] +transform = Transform3D(-0.98478, -0.0449895, -0.167903, 4.9018e-08, 0.965926, -0.258819, 0.173826, -0.25488, -0.951223, 38.7948, 36.2505, -70.1114) +use_collision = true +size = Vector3(17, 2.5, 3.38135) material = ExtResource("3_cieeo") [node name="CSGBox3D81" type="CSGBox3D" parent="Greybox/LowWageResidentialBulk1"] @@ -235,33 +401,27 @@ size = Vector3(12.5, 34.5, 15.5) material = ExtResource("3_cieeo") [node name="CSGBox3D40" type="CSGBox3D" parent="Greybox/LowWageResidentialBulk1"] -transform = Transform3D(-1, 0, 5.96046e-08, 0, 1, 0, -5.96046e-08, 0, -1, 21.1913, 12.75, -35.1075) +transform = Transform3D(-1, 0, 8.9407e-08, 0, 1, 0, -8.9407e-08, 0, -1, 21.9413, 12.75, -34.4471) use_collision = true -size = Vector3(8, 42.5, 19) +size = Vector3(9.5, 42.5, 20.3208) material = ExtResource("3_cieeo") [node name="CSGBox3D42" type="CSGBox3D" parent="Greybox/LowWageResidentialBulk1"] -transform = Transform3D(-0.984809, 0, -0.173648, 0, 1, 0, 0.173648, 0, -0.984809, 28.9676, 13.75, -34.2724) +transform = Transform3D(-0.984809, 0, -0.173648, 0, 1, 0, 0.173648, 0, -0.984809, 28.9676, 18.25, -34.2724) use_collision = true -size = Vector3(10.5, 44.5, 6.5) +size = Vector3(10.5, 53.5, 6.5) material = ExtResource("3_cieeo") [node name="CSGBox3D44" type="CSGBox3D" parent="Greybox/LowWageResidentialBulk1"] -transform = Transform3D(-0.996196, 0, 0.0871559, 0, 1, 0, -0.0871559, 0, -0.996196, 28.9539, 14.5, -41.4776) +transform = Transform3D(-0.996196, 0, 0.0871559, 0, 1, 0, -0.0871559, 0, -0.996196, 28.9539, 15.75, -41.4776) use_collision = true -size = Vector3(11, 46, 11) +size = Vector3(11, 48.5, 11) material = ExtResource("3_cieeo") [node name="CSGBox3D43" type="CSGBox3D" parent="Greybox/LowWageResidentialBulk1"] -transform = Transform3D(-0.866027, 0, -0.5, 0, 1, 0, 0.5, 0, -0.866027, 29.5069, 13.75, -30.9702) +transform = Transform3D(-0.866027, 0, -0.5, 0, 1, 0, 0.5, 0, -0.866027, 29.5069, 18.25, -30.9702) use_collision = true -size = Vector3(9.5, 44.5, 4) -material = ExtResource("3_cieeo") - -[node name="CSGBox3D41" type="CSGBox3D" parent="Greybox/LowWageResidentialBulk1"] -transform = Transform3D(-0.819153, 0, -0.573577, 0, 1, 0, 0.573577, 0, -0.819153, 20.577, 12.75, -25.9274) -use_collision = true -size = Vector3(9.5, 42.5, 3.5) +size = Vector3(9.5, 53.5, 4) material = ExtResource("3_cieeo") [node name="CSGBox3D14" type="CSGBox3D" parent="Greybox/LowWageResidentialBulk1"] @@ -439,9 +599,9 @@ size = Vector3(7, 30.5, 9.5) material = ExtResource("3_cieeo") [node name="CSGBox3D39" type="CSGBox3D" parent="Greybox/LowWageResidentialBulk1"] -transform = Transform3D(0.835489, 0, 0.54951, 0, 1, 0, -0.54951, 0, 0.835489, 15.441, 6, -15.3224) +transform = Transform3D(0.835489, 0, 0.54951, 0, 1, 0, -0.54951, 0, 0.835489, 14.7541, 6, -16.3668) use_collision = true -size = Vector3(19, 32, 9.5) +size = Vector3(19, 32, 12) material = ExtResource("3_cieeo") [node name="CSGBox3D48" type="CSGBox3D" parent="Greybox/LowWageResidentialBulk1"] @@ -451,9 +611,9 @@ size = Vector3(19, 1.5, 3.85) material = ExtResource("3_cieeo") [node name="CSGBox3D49" type="CSGBox3D" parent="Greybox/LowWageResidentialBulk1"] -transform = Transform3D(-0.835489, -0.142223, -0.530785, 1.99003e-08, 0.965926, -0.258819, 0.549509, -0.21624, -0.80702, 14.723, 21.9132, -16.8629) +transform = Transform3D(-0.835489, -0.142223, -0.530785, 1.99003e-08, 0.965926, -0.258819, 0.549509, -0.21624, -0.80702, 14.0595, 21.5897, -17.8717) use_collision = true -size = Vector3(18.95, 1.5, 6) +size = Vector3(18.95, 1.5, 8.5) material = ExtResource("3_cieeo") [node name="CSGBox3D50" type="CSGBox3D" parent="Greybox/LowWageResidentialBulk1"] @@ -528,6 +688,42 @@ use_collision = true size = Vector3(8, 2.5, 6.5) material = ExtResource("3_cieeo") +[node name="CSGBox3D71" type="CSGBox3D" parent="Greybox/LowWageResidentialBulk1"] +transform = Transform3D(-0.17527, 0.254812, 0.950975, 2.76232e-08, 0.965926, -0.258819, -0.984522, -0.0453627, -0.169298, 31.3255, 44.7558, -34.5483) +use_collision = true +size = Vector3(6.80225, 2, 5.47021) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D90" type="CSGBox3D" parent="Greybox/LowWageResidentialBulk1"] +transform = Transform3D(0.175269, -0.254813, -0.950975, 2.03337e-08, 0.965926, -0.258819, 0.984522, 0.0453628, 0.169297, 26.7037, 44.5328, -33.8839) +use_collision = true +size = Vector3(6.5, 2.5, 5.43604) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D91" type="CSGBox3D" parent="Greybox/LowWageResidentialBulk1"] +transform = Transform3D(0.501426, -0.223931, -0.835721, 1.20306e-08, 0.965926, -0.258819, 0.865203, 0.129778, 0.48434, 27.7153, 44.4813, -29.8682) +use_collision = true +size = Vector3(3.8844, 2.5, 5.03833) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D92" type="CSGBox3D" parent="Greybox/LowWageResidentialBulk1"] +transform = Transform3D(-0.501426, 0.223931, 0.835721, 1.20306e-08, 0.965926, -0.258819, -0.865203, -0.129778, -0.48434, 31.3598, 44.4864, -31.9628) +use_collision = true +size = Vector3(3.8584, 2.5, 5.07788) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D88" type="CSGBox3D" parent="Greybox/LowWageResidentialBulk1"] +transform = Transform3D(-1, -9.16272e-05, -0.000342578, 1.99003e-08, 0.965926, -0.258819, 0.00035429, -0.258819, -0.965927, 20.4544, 34.1536, -39.2039) +use_collision = true +size = Vector3(6.53027, 2.5, 10.5) +material = ExtResource("3_cieeo") + +[node name="CSGBox3D89" type="CSGBox3D" parent="Greybox/LowWageResidentialBulk1"] +transform = Transform3D(1, 9.16123e-05, 0.000342488, 1.99003e-08, 0.965926, -0.258819, -0.000354171, 0.258819, 0.965927, 21.9387, 34.1536, -29.7151) +use_collision = true +size = Vector3(9.5, 2.5, 10.5) +material = ExtResource("3_cieeo") + [node name="CSGBox3D54" type="CSGBox3D" parent="Greybox/LowWageResidentialBulk1"] transform = Transform3D(0.202218, 0.253472, 0.945972, 1.99003e-08, 0.965926, -0.258819, -0.979342, 0.0523378, 0.195327, 46.7459, 20.9447, -34.1385) use_collision = true diff --git a/player_controller/PlayerController.tscn b/player_controller/PlayerController.tscn index f2da6b5..04fcb41 100644 --- a/player_controller/PlayerController.tscn +++ b/player_controller/PlayerController.tscn @@ -34,13 +34,16 @@ [ext_resource type="PackedScene" uid="uid://ckm3d6k08a72u" path="res://systems/weapon/weapon.tscn" id="29_wv70j"] [sub_resource type="CapsuleMesh" id="CapsuleMesh_xc2g5"] +height = 1.7 [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_wydro"] +height = 1.7 [node name="Player" type="CharacterBody3D"] script = ExtResource("1_poq2x") TimeScaleAimInAir = 0.15 -MaxJumpBoostAfterDashing = 1.4 +MaxJumpBoostAfterDashing = 0.7 +MaxNumberOfDashActions = 3 [node name="InputController" type="Node3D" parent="."] script = ExtResource("16_v31n3") @@ -56,16 +59,18 @@ hit = ExtResource("11_cresl") drop = ExtResource("12_34snm") [node name="MeshInstance3D" type="MeshInstance3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.85, 0) +visible = false mesh = SubResource("CapsuleMesh_xc2g5") [node name="CapsuleCollider" type="CollisionShape3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.85, 0) shape = SubResource("CapsuleShape3D_wydro") script = ExtResource("8_lmtjd") +CapsuleDefaultHeight = 1.7 [node name="HeadSystem" parent="." instance=ExtResource("11_rxwoh")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.68, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.6, 0) [node name="HealthSystem" type="Node3D" parent="."] script = ExtResource("5_umw0l") @@ -85,10 +90,12 @@ target_position = Vector3(0, -0.75, 0) [node name="MantleSystem" parent="." instance=ExtResource("8_qu4wy")] MantleEndLocationDistanceFromWall = 0.3 -MantleHeightCastStart = 2.0 +MantleHeightCastStart = 1.5 [node name="Bobbing" type="Node3D" parent="."] script = ExtResource("10_7wk1w") +BobbingFrequency = 3.0 +BobbingAmplitude = 0.05 [node name="FieldOfView" type="Node3D" parent="."] script = ExtResource("12_m2mxi") @@ -113,14 +120,15 @@ target_position = Vector3(0, 1, 0) [node name="MoveSystem" type="Node3D" parent="."] script = ExtResource("20_rxwoh") -WalkSpeed = 10.0 -SprintSpeed = 15.0 -DoubleJumpSpeedFactor = 1.4 +WalkSpeed = 7.2 +DecelerationSpeedFactorFloor = 7.0 +ApexHoldTime = 0.1 [node name="Gravity" type="Node3D" parent="."] script = ExtResource("9_lsueh") -Weight = 6.5 -StartVelocity = 4.0 +Weight = 3.5 +StartVelocity = 0.7 +JumpFromDashSpeedFactor = 4.0 [node name="TweenQueueSystem" parent="." instance=ExtResource("22_rpwev")] @@ -173,7 +181,6 @@ offset_left = 1530.0 offset_top = 1.0 offset_right = -2.0 offset_bottom = 1.0 -enabled = false initial_node_to_watch = NodePath("../StateChart") [node name="StateChart" type="Node" parent="."] @@ -373,6 +380,12 @@ to = NodePath("../../DoubleJumpEnabled") event = &"to_double_jump" delay_in_seconds = "0.0" +[node name="ToFalling" type="Node" parent="StateChart/Root/Movement/Airborne/Jump"] +script = ExtResource("28_n7qhm") +to = NodePath("../../Falling") +event = &"jump_from_dash" +delay_in_seconds = "0.0" + [node name="JumpFromWall" type="Node" parent="StateChart/Root/Movement/Airborne"] script = ExtResource("27_34snm") @@ -382,6 +395,12 @@ to = NodePath("../../DoubleJumpEnabled") event = &"to_double_jump" delay_in_seconds = "0.0" +[node name="ToFalling" type="Node" parent="StateChart/Root/Movement/Airborne/JumpFromWall"] +script = ExtResource("28_n7qhm") +to = NodePath("../../Falling") +event = &"jump_from_dash" +delay_in_seconds = "0.0" + [node name="DoubleJumpEnabled" type="Node" parent="StateChart/Root/Movement/Airborne"] script = ExtResource("27_34snm") @@ -403,6 +422,12 @@ delay_in_seconds = "0.0" [node name="Falling" type="Node" parent="StateChart/Root/Movement/Airborne"] script = ExtResource("27_34snm") +[node name="ToDoubleJump" type="Node" parent="StateChart/Root/Movement/Airborne/Falling"] +script = ExtResource("28_n7qhm") +to = NodePath("../../DoubleJumpEnabled") +event = &"enable_double_jump" +delay_in_seconds = "0.0" + [connection signal="input_aim_canceled" from="InputController" to="." method="OnInputAimCanceled"] [connection signal="input_aim_pressed" from="InputController" to="." method="OnInputAimPressed"] [connection signal="input_aim_released" from="InputController" to="." method="OnInputAimReleased"] diff --git a/player_controller/Scripts/Gravity.cs b/player_controller/Scripts/Gravity.cs index 26bdb8b..a0e529c 100644 --- a/player_controller/Scripts/Gravity.cs +++ b/player_controller/Scripts/Gravity.cs @@ -4,12 +4,16 @@ namespace Movementtests.player_controller.Scripts; public partial class Gravity: Node3D { - [Export(PropertyHint.Range, "0,100,0.1,or_greater")] - public float Weight { get; set; } = 70.0f; - [Export(PropertyHint.Range, "0,20,0.1,or_greater")] - public float StartVelocity { get; set; } = 3.0f; - [Export(PropertyHint.Range, "0.01,10,0.01,or_greater")] - public float AdditionalGravityPower { get; set; } = 2f; + [Export(PropertyHint.Range, "0,10,0.01,or_greater")] + public float Weight { get; set; } = 3.0f; + [Export(PropertyHint.Range, "0,2,0.01,or_greater")] + public float StartVelocity { get; set; } = 1.0f; + [Export(PropertyHint.Range, "0.1,10,0.1,or_greater")] + public float DoubleJumpSpeedFactor { get; set; } = 2f; + [Export(PropertyHint.Range, "0.1,10,0.1,or_greater")] + public float JumpFromDashSpeedFactor { get; set; } = 2f; + [Export(PropertyHint.Range, "0,1,0.01,or_greater")] + public float AdditionalGravityPower { get; set; } = 1f; private float _gravity; @@ -19,5 +23,7 @@ public partial class Gravity: Node3D } public float CalculateJumpForce() => _gravity * (StartVelocity / AdditionalGravityPower); + public float CalculateJumpFromDashForce() => CalculateJumpForce() * JumpFromDashSpeedFactor; + public float CalculateDoubleJumpForce() => CalculateJumpForce() * DoubleJumpSpeedFactor; public float CalculateGravityForce() => _gravity * Weight; } diff --git a/player_controller/Scripts/PlayerController.cs b/player_controller/Scripts/PlayerController.cs index 3e3db5d..97178cd 100644 --- a/player_controller/Scripts/PlayerController.cs +++ b/player_controller/Scripts/PlayerController.cs @@ -3,6 +3,7 @@ using Godot; using GodotStateCharts; using Movementtests.systems; using Movementtests.player_controller.Scripts; +using RustyOptions; public partial class PlayerController : CharacterBody3D { @@ -38,17 +39,19 @@ public partial class PlayerController : CharacterBody3D private float _inputRotateY; private float _inputRotateFloorplane; - private bool _isAiming; - private bool _dashCanceled; - private Timer _coyoteTimer; private Timer _timeScaleAimInAirTimer; private Timer _timeAfterDashingTimer; [Export(PropertyHint.Range, "0,1,0.01,or_greater")] public float TimeScaleAimInAir { get; set; } = 0.2f; - [Export(PropertyHint.Range, "1,5,0.1,or_greater")] - public float MaxJumpBoostAfterDashing { get; set; } = 2f; + [Export(PropertyHint.Range, "0,5,0.1,or_greater")] + public float MaxJumpBoostAfterDashing { get; set; } = 1f; + + [Export(PropertyHint.Range, "0,5,1,or_greater")] + public int MaxNumberOfDashActions { get; set; } = 1; + public int DashActionsLeft { get; set; } + private StateChart _playerState; // Actions state private StateChartState _weaponInHand; @@ -177,6 +180,8 @@ public partial class PlayerController : CharacterBody3D }; HealthSystem.Init(healthSystemParams); Stamina.SetSpeeds(MoveSystem.WalkSpeed, MoveSystem.SprintSpeed); + + DashActionsLeft = MaxNumberOfDashActions; /////////////////////////// // Signal setup /////////// @@ -188,7 +193,8 @@ public partial class PlayerController : CharacterBody3D _aiming.StateProcessing += HandleAiming; _aiming.StateEntered += OnAimingEntered; _aiming.StateExited += ResetTimeScale; - + + _grounded.StateEntered += OnGrounded; _grounded.StatePhysicsProcessing += HandleGrounded; _airborne.StatePhysicsProcessing += HandleAirborne; _wallHugging.StatePhysicsProcessing += HandleWallHugging; @@ -256,6 +262,24 @@ public partial class PlayerController : CharacterBody3D /////////////////////////// // Stateful logic ///////// /////////////////////////// + + // Simple states + public void OnGrounded() + { + DashActionsLeft = MaxNumberOfDashActions; + GD.Print(DashActionsLeft); + } + + public bool CanPerformDashAction() + { + return DashActionsLeft > 0; + } + + public void PerformDashAction() + { + DashActionsLeft--; + GD.Print(DashActionsLeft); + } // Jumping public void StartCoyoteTime() @@ -268,36 +292,56 @@ public partial class PlayerController : CharacterBody3D } public void Jump() { + if (_aiming.Active && CanPerformDashAction()) + { + _playerState.SendEvent("jump_from_dash"); + PerformDashAction(); + PerformJump(MoveSystem.JumpTypes.JUMP_FROM_DASH); + return; + } _playerState.SendEvent("to_double_jump"); - PerformJump(false); + PerformJump(MoveSystem.JumpTypes.SIMPLE_JUMP); } public void JumpFromWall() { + var wallNormal = WallHugSystem.GetWallNormal().UnwrapOr(Vector3.Up); + if (_aiming.Active && CanPerformDashAction()) + { + _playerState.SendEvent("jump_from_dash"); + PerformDashAction(); + PerformJump(MoveSystem.JumpTypes.JUMP_FROM_DASH, wallNormal); + return; + } _playerState.SendEvent("to_double_jump"); - var wallNormal = WallHugSystem.GetWallNormal(); - if (wallNormal.IsSome(out var normal)) - PerformJump(false, normal); - PerformJump(false); + PerformJump(MoveSystem.JumpTypes.SIMPLE_JUMP, wallNormal); } public void DoubleJump() { _playerState.SendEvent("to_falling"); - PerformJump(true); + if (_aiming.Active && CanPerformDashAction()) + { + PerformDashAction(); + PerformJump(MoveSystem.JumpTypes.JUMP_FROM_DASH); + return; + } + PerformJump(MoveSystem.JumpTypes.DOUBLE_JUMP); } - private void PerformJump(bool isDoubleJump, Vector3? jumpDirection = null) + private void PerformJump(MoveSystem.JumpTypes jumpType, Vector3? jumpDirection = null) { var effectiveJumpDirection = jumpDirection ?? Vector3.Up; var jumpVector = (effectiveJumpDirection.Normalized() + Vector3.Up).Normalized(); var proportionOfTimeGone = _timeAfterDashingTimer.TimeLeft / _timeAfterDashingTimer.WaitTime; - GD.Print(proportionOfTimeGone); var actualBoost = 1 + MaxJumpBoostAfterDashing * proportionOfTimeGone; + var makeItDouble = actualBoost > 1; + if (makeItDouble && jumpType == MoveSystem.JumpTypes.SIMPLE_JUMP) + jumpType = MoveSystem.JumpTypes.DOUBLE_JUMP; // convert simple jump to double if done right after a dash _timeAfterDashingTimer.Stop(); bool doesCapsuleHaveCrouchingHeight = CapsuleCollider.IsCrouchingHeight(); bool isPlayerDead = HealthSystem.IsDead(); if (!doesCapsuleHaveCrouchingHeight && !isPlayerDead) - MoveSystem.Jump(isDoubleJump, jumpVector, (float) actualBoost); + MoveSystem.Jump(jumpType, jumpVector, (float) actualBoost); } // Mantling @@ -315,6 +359,15 @@ public partial class PlayerController : CharacterBody3D // Dashing and weapon throwing public void OnDashStarted() { + if (!CanPerformDashAction()) + { + _playerState.SendEvent("aim_canceled"); + _playerState.SendEvent("dash_ended"); + DashSystem.CancelDash(); + return; + } + + PerformDashAction(); _timeAfterDashingTimer.Start(); if (WeaponSystem.FlyingState.Active) { @@ -330,6 +383,7 @@ public partial class PlayerController : CharacterBody3D } public void OnDashEnded() { + // _playerState.SendEvent("enable_double_jump"); // Allow for double jump after dash -- OP ? // Regular dash if (WeaponSystem.InHandState.Active) { @@ -379,7 +433,7 @@ public partial class PlayerController : CharacterBody3D } public void OnAimingEntered() { - if (!isOnFloorCustom()) + if (!isOnFloorCustom() && CanPerformDashAction()) ReduceTimeScaleWhileAiming(); } @@ -391,10 +445,15 @@ public partial class PlayerController : CharacterBody3D public void HandleAiming(float delta) { RotateWeaponWithPlayer(); - DashSystem.PrepareDash(); - if (isOnFloorCustom()) ResetTimeScale(); + if (CanPerformDashAction()) + DashSystem.PrepareDash(); + else + { + _playerState.SendEvent("aim_canceled"); + DashSystem.CancelDash(); + } } // Physics processes diff --git a/systems/mantle/mantle_system.tscn b/systems/mantle/mantle_system.tscn index 4de928e..d7eb43a 100644 --- a/systems/mantle/mantle_system.tscn +++ b/systems/mantle/mantle_system.tscn @@ -3,9 +3,10 @@ [ext_resource type="Script" uid="uid://bja6tis1vaysu" path="res://systems/mantle/MantleSystem.cs" id="1_2oobp"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_4coqe"] +height = 1.7 [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_qu4wy"] -height = 1.5 +height = 1.3 [node name="MantleSystem" type="Node3D"] script = ExtResource("1_2oobp") diff --git a/systems/move/MoveSystem.cs b/systems/move/MoveSystem.cs index 1d03d1e..cc83dfb 100644 --- a/systems/move/MoveSystem.cs +++ b/systems/move/MoveSystem.cs @@ -6,6 +6,13 @@ namespace Movementtests.systems; public partial class MoveSystem : Node3D { + public enum JumpTypes + { + SIMPLE_JUMP, + DOUBLE_JUMP, + JUMP_FROM_DASH + } + public record MoveSystemParameters( CharacterBody3D Parent, Gravity Gravity, @@ -33,13 +40,19 @@ public partial class MoveSystem : Node3D [Export(PropertyHint.Range, "0,100,0.1,or_greater")] public float _currentSpeed; - private const float DecelerationSpeedFactorFloor = 5.0f; - private const float DecelerationSpeedFactorAir = 1.0f; + [Export(PropertyHint.Range, "0,10,0.1,or_greater")] + public float AccelerationSpeedFactorFloor = 5.0f; + [Export(PropertyHint.Range, "0,10,0.1,or_greater")] + public float DecelerationSpeedFactorFloor = 5.0f; + [Export(PropertyHint.Range, "0,10,0.1,or_greater")] + public float DecelerationSpeedFactorAir = 1.0f; + [Export(PropertyHint.Range, "0,1,0.01,or_greater")] + public float ApexHoldTime = 0.0f; + private float _timeLeftAtApex = 0.0f; + private bool _wasGoingUpLastFrame = false; public float CrouchTransitionSpeed { get; set; } = 20.0f; [Export(PropertyHint.Range, "0,5,0.1,or_greater")] - public float DoubleJumpSpeedFactor { get; set; } = 2f; - [Export(PropertyHint.Range, "0,1,0.01,or_greater")] public float WallHugGravityReducingFactor { get; set; } = 0.1f; @@ -61,6 +74,11 @@ public partial class MoveSystem : Node3D _currentSpeed = WalkSpeed; } + private bool IsGoingUp() + { + return _parent.Velocity.Y > 0; + } + public void MoveAround(MoveAroundParameters param) { var (delta, movementDirection, isOnFloor, isDead, isHeadTouchingCeiling, isHanging, isWallHugging) = param; @@ -68,6 +86,12 @@ public partial class MoveSystem : Node3D var doesCapsuleHaveCrouchingHeight = _capsuleCollider.IsCrouchingHeight(); var doesCapsuleHaveDefaultHeight = _capsuleCollider.IsDefaultHeight(); + if (IsGoingUp() || isOnFloor) + { + _wasGoingUpLastFrame = true; + _timeLeftAtApex = ApexHoldTime; + } + if (isHanging) { _parent.Velocity = Vector3.Zero; @@ -86,10 +110,21 @@ public partial class MoveSystem : Node3D // Adding the gravity if (!isOnFloor) { - _parent.Velocity = new Vector3( - x: _parent.Velocity.X, - y: _parent.Velocity.Y - (_gravity.CalculateGravityForce() * (float)delta), - z: _parent.Velocity.Z); + if (!IsGoingUp() && _wasGoingUpLastFrame && _timeLeftAtApex > 0) + { + _parent.Velocity = new Vector3( + x: _parent.Velocity.X, + y: 0, + z: _parent.Velocity.Z); + _timeLeftAtApex -= (float) delta; + } + else + { + _parent.Velocity = new Vector3( + x: _parent.Velocity.X, + y: _parent.Velocity.Y - (_gravity.CalculateGravityForce() * (float)delta), + z: _parent.Velocity.Z); + } } // The code below is required to quickly adjust player's position on Y-axis when there's a ceiling on the @@ -139,38 +174,15 @@ public partial class MoveSystem : Node3D { direction = Vector3.Zero; } + + var accelerationFloorFactor = direction.Length() > 0 ? AccelerationSpeedFactorFloor : DecelerationSpeedFactorFloor; + var accelerationFactor = isOnFloor ? accelerationFloorFactor : DecelerationSpeedFactorAir; - - if (isOnFloor) - { - // Set velocity based on input direction when on the floor - if (direction.Length() > 0) - { - float newX = direction.X * _currentSpeed; - float newZ = direction.Z * _currentSpeed; - - _parent.Velocity = new Vector3(newX, _parent.Velocity.Y, newZ); - } - // If there is no input, smoothly decelerate the character on the floor - else - { - float xDeceleration = Mathf.Lerp(_parent.Velocity.X, direction.X * _currentSpeed, - (float)delta * DecelerationSpeedFactorFloor); - float zDeceleration = Mathf.Lerp(_parent.Velocity.Z, direction.Z * _currentSpeed, - (float)delta * DecelerationSpeedFactorFloor); - - _parent.Velocity = new Vector3(xDeceleration, _parent.Velocity.Y, zDeceleration); - } - } - else - { - float xDeceleration = Mathf.Lerp(_parent.Velocity.X, direction.X * _currentSpeed, - (float)delta * DecelerationSpeedFactorAir); - float zDeceleration = Mathf.Lerp(_parent.Velocity.Z, direction.Z * _currentSpeed, - (float)delta * DecelerationSpeedFactorAir); - - _parent.Velocity = new Vector3(xDeceleration, _parent.Velocity.Y, zDeceleration); - } + float xAcceleration = Mathf.Lerp(_parent.Velocity.X, direction.X * _currentSpeed, + (float)delta * accelerationFactor); + float zAcceleration = Mathf.Lerp(_parent.Velocity.Z, direction.Z * _currentSpeed, + (float)delta * accelerationFactor); + _parent.Velocity = new Vector3(xAcceleration, _parent.Velocity.Y, zAcceleration); if (isDead) { @@ -178,12 +190,25 @@ public partial class MoveSystem : Node3D } } - public void Jump(bool isDoubleJump, Vector3? jumpDirection = null, float boost = 1.0f) + public void Jump(JumpTypes jumpType, Vector3? jumpDirection = null, float boost = 1.0f) { var effectiveJumpDirection = jumpDirection ?? Vector3.Up; - var jumpForce = isDoubleJump - ? _gravity.CalculateJumpForce() * DoubleJumpSpeedFactor - : _gravity.CalculateJumpForce(); + var jumpForce = 0.0f; + switch (jumpType) + { + case JumpTypes.DOUBLE_JUMP: + jumpForce = _gravity.CalculateDoubleJumpForce(); + break; + case JumpTypes.SIMPLE_JUMP: + jumpForce = _gravity.CalculateJumpForce(); + break; + case JumpTypes.JUMP_FROM_DASH: + jumpForce = _gravity.CalculateJumpFromDashForce(); + break; + default: + jumpForce = _gravity.CalculateJumpForce(); + break; + } var currentHorizontalVelocity = new Vector3(_parent.Velocity.X, 0, _parent.Velocity.Z); var jumpVelocity = jumpForce * effectiveJumpDirection * boost;