diff --git a/addons/maaacks_game_template/base/scenes/overlaid_menu/overlaid_menu_container.gd b/addons/maaacks_game_template/base/scenes/overlaid_menu/overlaid_menu_container.gd index f33b39dc..ec4f4553 100644 --- a/addons/maaacks_game_template/base/scenes/overlaid_menu/overlaid_menu_container.gd +++ b/addons/maaacks_game_template/base/scenes/overlaid_menu/overlaid_menu_container.gd @@ -12,5 +12,3 @@ extends OverlaidMenu if menu_scene: var _instance = menu_scene.instantiate() %MenuContainer.add_child(_instance) - - diff --git a/maps/levels/tuto_movement.tscn b/maps/levels/tuto_movement.tscn index e8dca5d5..1a31b175 100644 --- a/maps/levels/tuto_movement.tscn +++ b/maps/levels/tuto_movement.tscn @@ -27,7 +27,7 @@ size = Vector3(3, 12.5, 6) size = Vector3(3.5, 7, 10.5) [sub_resource type="BoxShape3D" id="BoxShape3D_6rkcg"] -size = Vector3(5.5, 6.5, 3) +size = Vector3(10, 6.5, 3) [sub_resource type="BoxShape3D" id="BoxShape3D_p8dgc"] size = Vector3(3, 6.5, 5.5) @@ -762,119 +762,148 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -17.5, 22.5, -51.5) [node name="OmniLight3D" type="OmniLight3D" parent="Lights" index="0" unique_id=1759925856] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4, 2, -12) -omni_range = 6.0 +light_energy = 2.249 +omni_range = 9.0 -[node name="OmniLight3D2" type="OmniLight3D" parent="Lights" index="1" unique_id=458028986] +[node name="OmniLight3D28" type="OmniLight3D" parent="Lights" index="1" unique_id=1996817466] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 4, -3) +light_energy = 2.825 +omni_range = 9.0 + +[node name="OmniLight3D2" type="OmniLight3D" parent="Lights" index="2" unique_id=458028986] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -14.5, 2.5, -18) -omni_range = 6.0 +light_energy = 2.405 +omni_range = 10.0 -[node name="OmniLight3D3" type="OmniLight3D" parent="Lights" index="2" unique_id=735245103] +[node name="OmniLight3D3" type="OmniLight3D" parent="Lights" index="3" unique_id=735245103] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -16, 7, -39.5) +light_energy = 3.966 omni_range = 9.5 -[node name="OmniLight3D31" type="OmniLight3D" parent="Lights" index="3" unique_id=829009277] +[node name="OmniLight3D31" type="OmniLight3D" parent="Lights" index="4" unique_id=829009277] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -14, 4.5, -24.5) +light_energy = 2.405 omni_range = 9.5 -[node name="OmniLight3D4" type="OmniLight3D" parent="Lights" index="4" unique_id=92911518] +[node name="OmniLight3D4" type="OmniLight3D" parent="Lights" index="5" unique_id=92911518] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 5.5, -38.5) omni_range = 5.5 -[node name="OmniLight3D30" type="OmniLight3D" parent="Lights" index="5" unique_id=697077536] +[node name="OmniLight3D30" type="OmniLight3D" parent="Lights" index="6" unique_id=697077536] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -7.5, 3, -38.5) -[node name="OmniLight3D5" type="OmniLight3D" parent="Lights" index="6" unique_id=1550409099] +[node name="OmniLight3D5" type="OmniLight3D" parent="Lights" index="7" unique_id=1550409099] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 11.5, 9.5, -39) +omni_range = 10.5 + +[node name="OmniLight3D32" type="OmniLight3D" parent="Lights" index="8" unique_id=283937628] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4.5, 9.5, -39) +light_energy = 1.695 omni_range = 6.5 -[node name="OmniLight3D6" type="OmniLight3D" parent="Lights" index="7" unique_id=342293346] +[node name="OmniLight3D6" type="OmniLight3D" parent="Lights" index="9" unique_id=342293346] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 12, 10.5, -32) omni_range = 3.5 -[node name="OmniLight3D7" type="OmniLight3D" parent="Lights" index="8" unique_id=1443833930] +[node name="OmniLight3D7" type="OmniLight3D" parent="Lights" index="10" unique_id=1443833930] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 12, 19.5, -32) -omni_range = 8.0 +light_energy = 3.576 +omni_range = 10.0 -[node name="OmniLight3D8" type="OmniLight3D" parent="Lights" index="9" unique_id=260674221] +[node name="OmniLight3D8" type="OmniLight3D" parent="Lights" index="11" unique_id=260674221] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 12, 20, -15) omni_range = 4.0 -[node name="OmniLight3D9" type="OmniLight3D" parent="Lights" index="10" unique_id=1269832640] +[node name="OmniLight3D9" type="OmniLight3D" parent="Lights" index="12" unique_id=1269832640] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 12, 20, 3.5) omni_range = 4.0 -[node name="OmniLight3D10" type="OmniLight3D" parent="Lights" index="11" unique_id=21886206] +[node name="OmniLight3D10" type="OmniLight3D" parent="Lights" index="13" unique_id=21886206] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 12, 17.5, -6.5) omni_range = 7.5 -[node name="OmniLight3D11" type="OmniLight3D" parent="Lights" index="12" unique_id=1631281854] +[node name="OmniLight3D11" type="OmniLight3D" parent="Lights" index="14" unique_id=1631281854] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 12, 17.5, 11.5) omni_range = 7.5 -[node name="OmniLight3D12" type="OmniLight3D" parent="Lights" index="13" unique_id=1292223180] +[node name="OmniLight3D12" type="OmniLight3D" parent="Lights" index="15" unique_id=1292223180] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 5.5, 19, 17.5) omni_range = 4.5 -[node name="OmniLight3D15" type="OmniLight3D" parent="Lights" index="14" unique_id=895379786] +[node name="OmniLight3D15" type="OmniLight3D" parent="Lights" index="16" unique_id=895379786] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -16.5, 21, 22.5) omni_range = 3.5 -[node name="OmniLight3D18" type="OmniLight3D" parent="Lights" index="15" unique_id=277657948] +[node name="OmniLight3D18" type="OmniLight3D" parent="Lights" index="17" unique_id=277657948] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -24.5, 24.5, 17.5) +light_energy = 5.293 omni_range = 15.5 -[node name="OmniLight3D13" type="OmniLight3D" parent="Lights" index="16" unique_id=305122268] +[node name="OmniLight3D13" type="OmniLight3D" parent="Lights" index="18" unique_id=305122268] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 11, 22.5, 20.5) -omni_range = 7.0 - -[node name="OmniLight3D14" type="OmniLight3D" parent="Lights" index="17" unique_id=915168140] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5, 22.5, 17.5) +light_energy = 2.015 omni_range = 10.0 -[node name="OmniLight3D16" type="OmniLight3D" parent="Lights" index="18" unique_id=1080888977] +[node name="OmniLight3D33" type="OmniLight3D" parent="Lights" index="19" unique_id=333614135] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 11, 22.5, 15) +light_energy = 2.02 +omni_range = 10.0 + +[node name="OmniLight3D14" type="OmniLight3D" parent="Lights" index="20" unique_id=915168140] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -7.5, 22.5, 17.5) +light_energy = 4.278 +omni_range = 10.0 + +[node name="OmniLight3D16" type="OmniLight3D" parent="Lights" index="21" unique_id=1080888977] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -35.5, 25.5, 22) omni_range = 7.0 -[node name="OmniLight3D17" type="OmniLight3D" parent="Lights" index="19" unique_id=922282838] +[node name="OmniLight3D17" type="OmniLight3D" parent="Lights" index="22" unique_id=922282838] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -36.5, 25.5, 10.5) +light_energy = 1.775 omni_range = 7.0 -[node name="OmniLight3D19" type="OmniLight3D" parent="Lights" index="20" unique_id=1959866895] +[node name="OmniLight3D19" type="OmniLight3D" parent="Lights" index="23" unique_id=1959866895] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -37, 25.5, -5.5) +light_energy = 8.571 omni_range = 7.0 -[node name="OmniLight3D29" type="OmniLight3D" parent="Lights" index="21" unique_id=2143811783] +[node name="OmniLight3D29" type="OmniLight3D" parent="Lights" index="24" unique_id=2143811783] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -37, 25.5, -16.5) +light_energy = 4.004 omni_range = 7.0 -[node name="OmniLight3D20" type="OmniLight3D" parent="Lights" index="22" unique_id=1665621589] +[node name="OmniLight3D20" type="OmniLight3D" parent="Lights" index="25" unique_id=1665621589] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -37, 24.5, -29) omni_range = 7.0 -[node name="OmniLight3D21" type="OmniLight3D" parent="Lights" index="23" unique_id=1870279999] +[node name="OmniLight3D21" type="OmniLight3D" parent="Lights" index="26" unique_id=1870279999] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -37, 24.5, -29) +light_energy = 3.654 omni_range = 7.0 -[node name="OmniLight3D22" type="OmniLight3D" parent="Lights" index="24" unique_id=1284564847] +[node name="OmniLight3D22" type="OmniLight3D" parent="Lights" index="27" unique_id=1284564847] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -37, 24.5, -39.5) +light_energy = 1.825 +omni_range = 7.0 + +[node name="OmniLight3D23" type="OmniLight3D" parent="Lights" index="28" unique_id=1612575478] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -37, 24.5, -39.5) omni_range = 7.0 -[node name="OmniLight3D23" type="OmniLight3D" parent="Lights" index="25" unique_id=1612575478] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -37, 24.5, -39.5) -omni_range = 7.0 - -[node name="OmniLight3D24" type="OmniLight3D" parent="Lights" index="26" unique_id=1748145610] +[node name="OmniLight3D24" type="OmniLight3D" parent="Lights" index="29" unique_id=1748145610] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -33.5, 24.5, -47) +light_energy = 2.725 omni_range = 10.0 -[node name="OmniLight3D25" type="OmniLight3D" parent="Lights" index="27" unique_id=727558952] +[node name="OmniLight3D25" type="OmniLight3D" parent="Lights" index="30" unique_id=727558952] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -28, 24.5, -51) -[node name="OmniLight3D26" type="OmniLight3D" parent="Lights" index="28" unique_id=1646376304] +[node name="OmniLight3D26" type="OmniLight3D" parent="Lights" index="31" unique_id=1646376304] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -20, 24.5, -51.5) omni_range = 7.0 -[node name="OmniLight3D27" type="OmniLight3D" parent="Lights" index="29" unique_id=1849438050] +[node name="OmniLight3D27" type="OmniLight3D" parent="Lights" index="32" unique_id=1849438050] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -20, 24.5, -51.5) omni_range = 4.5 @@ -931,17 +960,17 @@ shape = SubResource("BoxShape3D_5ibpd") [node name="TutoTrigger6" parent="Tutorials" index="5" unique_id=1739438130 instance=ExtResource("7_r26ni")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 5, 19, 19) first_input_texture = ExtResource("8_6c6r2") -complex_input_text = "while mantling" +complex_input_text = "double tap during mantle" tuto_text = "Improved jump" [node name="CollisionShape3D" type="CollisionShape3D" parent="Tutorials/TutoTrigger6" index="1" unique_id=821335302] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.25, 0.25, -1.5) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.5, 0.25, -1.5) shape = SubResource("BoxShape3D_6rkcg") [node name="TutoTrigger7" parent="Tutorials" index="6" unique_id=1993844947 instance=ExtResource("7_r26ni")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -17.5, 21, 24) first_input_texture = ExtResource("8_6c6r2") -complex_input_text = "double tap" +complex_input_text = "double tap during mantle" tuto_text = "Try to wall run" [node name="CollisionShape3D" type="CollisionShape3D" parent="Tutorials/TutoTrigger7" index="1" unique_id=1194306224] diff --git a/scenes/player_controller/PlayerController.tscn b/scenes/player_controller/PlayerController.tscn index 28d4ccc8..ceb72970 100644 --- a/scenes/player_controller/PlayerController.tscn +++ b/scenes/player_controller/PlayerController.tscn @@ -151,6 +151,8 @@ AirGlideJumpSpeedFactor = 0.05 WallHugGravityLesseningFactor = 15.0 WallHugDownwardMaxSpeed = 4.0 WallHugHorizontalDeceleration = 1.0 +WallRunUpwardVelocityFactor = 0.5 +MinimumWallRunUpwardVelocity = 3.0 [node name="CHealth" parent="." unique_id=1244478698 instance=ExtResource("3_q7bng")] RHealth = ExtResource("4_m8gvy") @@ -969,12 +971,6 @@ initial_state = NodePath("CoyoteEnabled") script = ExtResource("41_ruloh") default_state = NodePath("../CoyoteEnabled") -[node name="OnWallRun" type="Node" parent="StateChart/Root/Movement/Airborne" unique_id=1722464777] -script = ExtResource("28_n7qhm") -to = NodePath("../../OnWall/Running") -event = &"wall_run" -delay_in_seconds = "0.0" - [node name="OnDash" type="Node" parent="StateChart/Root/Movement/Airborne" unique_id=30865998] script = ExtResource("28_n7qhm") to = NodePath("../../Dashing/Dash") @@ -1017,6 +1013,12 @@ delay_in_seconds = "0.0" [node name="DoubleJumpEnabled" type="Node" parent="StateChart/Root/Movement/Airborne" unique_id=1494014836] script = ExtResource("27_34snm") +[node name="OnWallRun" type="Node" parent="StateChart/Root/Movement/Airborne/DoubleJumpEnabled" unique_id=1722464777] +script = ExtResource("28_n7qhm") +to = NodePath("../../../OnWall/Running") +event = &"wall_run" +delay_in_seconds = "0.0" + [node name="OnSlide" type="Node" parent="StateChart/Root/Movement/Airborne/DoubleJumpEnabled" unique_id=1782099655] script = ExtResource("28_n7qhm") to = NodePath("../../../Sliding/AirGlideDoubleJumpEnabled") @@ -1038,6 +1040,12 @@ delay_in_seconds = "0.0" [node name="Falling" type="Node" parent="StateChart/Root/Movement/Airborne" unique_id=298940416] script = ExtResource("27_34snm") +[node name="OnWallRun" type="Node" parent="StateChart/Root/Movement/Airborne/Falling" unique_id=2118960256] +script = ExtResource("28_n7qhm") +to = NodePath("../../../OnWall/Running") +event = &"wall_run" +delay_in_seconds = "0.0" + [node name="OnSlide" type="Node" parent="StateChart/Root/Movement/Airborne/Falling" unique_id=1416873064] script = ExtResource("28_n7qhm") to = NodePath("../../../Sliding/AirGlide") @@ -1090,6 +1098,12 @@ to = NodePath("../../Jump/SimpleJump") event = &"jump" delay_in_seconds = "0.0" +[node name="OnDash" type="Node" parent="StateChart/Root/Movement/OnWall" unique_id=43147957] +script = ExtResource("28_n7qhm") +to = NodePath("../../Dashing/Dash") +event = &"dash" +delay_in_seconds = "0.0" + [node name="Hugging" type="Node" parent="StateChart/Root/Movement/OnWall" unique_id=162057636] script = ExtResource("27_34snm") @@ -1099,21 +1113,9 @@ to = NodePath("../../Running") event = &"wall_run" delay_in_seconds = "0.0" -[node name="OnDash" type="Node" parent="StateChart/Root/Movement/OnWall/Hugging" unique_id=43147957] -script = ExtResource("28_n7qhm") -to = NodePath("../../../Dashing/Dash") -event = &"dash" -delay_in_seconds = "0.0" - [node name="Hanging" type="Node" parent="StateChart/Root/Movement/OnWall" unique_id=1208015492] script = ExtResource("27_34snm") -[node name="OnDash" type="Node" parent="StateChart/Root/Movement/OnWall/Hanging" unique_id=1302363848] -script = ExtResource("28_n7qhm") -to = NodePath("../../../Dashing/Dash") -event = &"dash" -delay_in_seconds = "0.0" - [node name="Running" type="Node" parent="StateChart/Root/Movement/OnWall" unique_id=766545186] script = ExtResource("27_34snm") @@ -1123,6 +1125,12 @@ to = NodePath("../../../Airborne/CoyoteEnabled") event = &"start_falling" delay_in_seconds = "0.0" +[node name="OnNotEnoughSpeed" type="Node" parent="StateChart/Root/Movement/OnWall/Running" unique_id=539896633] +script = ExtResource("28_n7qhm") +to = NodePath("../../Hugging") +event = &"wall_hug" +delay_in_seconds = "0.0" + [connection signal="input_aim_down" from="InputController" to="." method="OnInputAimDown"] [connection signal="input_aim_pressed" from="InputController" to="." method="OnInputAimPressed"] [connection signal="input_aim_released" from="InputController" to="." method="OnInputAimReleased"] diff --git a/scenes/player_controller/scripts/PlayerController.cs b/scenes/player_controller/scripts/PlayerController.cs index 65d4a477..b88c4589 100644 --- a/scenes/player_controller/scripts/PlayerController.cs +++ b/scenes/player_controller/scripts/PlayerController.cs @@ -229,8 +229,10 @@ public partial class PlayerController : CharacterBody3D, // Wall run [ExportGroup("Wall run")] - [Export(PropertyHint.Range, "1,20,0.1,or_greater")] - public float WallRunUpwardVelocity { get; set; } = 10f; + [Export(PropertyHint.Range, "0,2,0.01,or_greater")] + public float WallRunUpwardVelocityFactor { get; set; } = 0.05f; + [Export(PropertyHint.Range, "0,10,0.1,or_greater")] + public float MinimumWallRunUpwardVelocity { get; set; } = 2f; [Export(PropertyHint.Range, "1,20,0.1,or_greater")] public float WallRunAltitudeLossSpeed { get; set; } = 10f; @@ -851,7 +853,7 @@ public partial class PlayerController : CharacterBody3D, // Should we start a wall run if (ShouldStartWallRun()) { - SetVerticalVelocity(WallRunUpwardVelocity); + SetVerticalVelocity(GetWallRunStartVerticalVelocity()); _playerState.SendEvent("wall_run"); return; } @@ -864,19 +866,6 @@ public partial class PlayerController : CharacterBody3D, } } - public bool ShouldStartWallRun() - { - var wallNormal = WallHugSystem.WallHugNormal.UnwrapOr(Vector3.Zero); - var isIndeedWall = wallNormal.Y < 0.1; - var hvel = new Vector3(Velocity.X, 0, Velocity.Z); - var hvelProjected = hvel.Slide(_wallHugStartNormal); - var haveEnoughSpeed = hvelProjected.Length() > WallRunSpeedThreshold; - var isCoplanarEnough = Velocity.AngleTo(wallNormal) > Math.PI/4 && Velocity.AngleTo(wallNormal) < 3*Math.PI/4; - var isGoingDownwards = Velocity.AngleTo(Vector3.Down) < Math.PI/4; - var shouldStart = haveEnoughSpeed && isCoplanarEnough && !isGoingDownwards && isIndeedWall; - return shouldStart; - } - public float ComputeVerticalSpeedGravity(float delta) { return Velocity.Y - CalculateGravityForce() * delta; @@ -1168,7 +1157,8 @@ public partial class PlayerController : CharacterBody3D, WallHug(delta); if (ShouldStartWallRun()) { - SetVerticalVelocity(WallRunUpwardVelocity); + var verticalVelocity = GetWallRunStartVerticalVelocity(); + SetVerticalVelocity(verticalVelocity); _playerState.SendEvent("wall_run"); return; } @@ -1183,8 +1173,8 @@ public partial class PlayerController : CharacterBody3D, } public void HandleWallRunning(float delta) { - _canDash = false; - _canDashAirborne = false; + // _canDash = false; + // _canDashAirborne = false; // Find horizontal velocity projected on the current wall var hvel = new Vector3(Velocity.X, 0, Velocity.Z); @@ -1196,7 +1186,7 @@ public partial class PlayerController : CharacterBody3D, // Adapt vertical speed var verticalSpeed = Velocity.Y - WallRunAltitudeLossSpeed * delta; Velocity = finalHVel + Vector3.Up*verticalSpeed; - Velocity *= 0.999f; + // Velocity *= 0.999f; _currentWallContactPoint = WallHugSystem.WallHugLocation.UnwrapOr(Vector3.Zero); @@ -1204,7 +1194,42 @@ public partial class PlayerController : CharacterBody3D, _playerState.SendEvent("grounded"); if (!WallHugSystem.IsWallHugging()) _playerState.SendEvent("start_falling"); + if (Velocity.Length() < WallRunSpeedThreshold / 2f) + _playerState.SendEvent("wall_hug"); } + + public float GetWallRunStartVerticalVelocity() + { + var hvel = new Vector3(Velocity.X, 0, Velocity.Z); + var hvelProjected = hvel.Slide(_wallHugStartNormal); + return Mathf.Max(hvelProjected.Length() * WallRunUpwardVelocityFactor, MinimumWallRunUpwardVelocity); + } + + public bool ShouldStartWallRun() + { + var wallNormal = WallHugSystem.WallHugNormal.UnwrapOr(Vector3.Zero); + var isIndeedWall = wallNormal.Y < 0.1; + var hvel = new Vector3(Velocity.X, 0, Velocity.Z); + var hvelProjected = hvel.Slide(_wallHugStartNormal); + var haveEnoughSpeed = Velocity.Length() > WallRunSpeedThreshold; + var isCoplanarEnough = Velocity.AngleTo(wallNormal) > Math.PI/4 && Velocity.AngleTo(wallNormal) < 3*Math.PI/4; + var isGoingDownwards = Velocity.AngleTo(Vector3.Down) < Math.PI/4; + var isLookingInDirectionOfRun = hvelProjected.AngleTo(-HeadSystem.GetForwardHorizontalVector()) < Math.PI/2; + var shouldStart = haveEnoughSpeed && isCoplanarEnough && !isGoingDownwards && isIndeedWall && isLookingInDirectionOfRun; + + var debugText = "--------------\n"; + debugText += shouldStart ? "WALL RUN STARTED\n" : "NO WALL RUN\n"; + debugText += $"Enough speed? {haveEnoughSpeed}\n"; + debugText += $"Coplanar enough? {isCoplanarEnough}\n"; + debugText += $"Going downwards? {isGoingDownwards} with angle {Velocity.AngleTo(Vector3.Down)}\n"; + debugText += $"Is looking in direction of run? {isLookingInDirectionOfRun} with angle {hvelProjected.AngleTo(-HeadSystem.GetForwardHorizontalVector())}\n"; + debugText += $"HVelocity on wall: {hvelProjected} - Forward H Vector: {-HeadSystem.GetForwardHorizontalVector()}\n"; + debugText += "--------------\n"; + //GD.Print(debugText); + + return shouldStart; + } + public void WallHug(float delta) { var hvel = ComputeHVelocity(delta, WallHugHorizontalDeceleration, WallHugHorizontalDeceleration); @@ -1794,7 +1819,7 @@ public partial class PlayerController : CharacterBody3D, var plannedDashLocation = targetable.GetTargetGlobalPosition() + Vector3.Down*_playerHeight/2; travel = plannedDashLocation - GlobalPosition; _dashDirection = travel.Normalized(); - var postDashLocation = plannedDashLocation + _dashDirection; + var postDashLocation = plannedDashLocation + 2*_dashDirection; var wallBehindQuery = PhysicsRayQueryParameters3D.Create(GlobalPosition + Vector3.Up*HeadSystem.Position.Y, postDashLocation, GroundDetector.CollisionMask); var wallBehindResult = _spaceState.IntersectRay(wallBehindQuery); shouldRebound = wallBehindResult.Count > 0; @@ -2131,7 +2156,7 @@ public partial class PlayerController : CharacterBody3D, var travel = plannedDashLocation - GlobalPosition; _dashDirection = travel.Normalized(); - var postDashLocation = plannedDashLocation + _dashDirection; + var postDashLocation = plannedDashLocation + 2*_dashDirection; var wallBehindQuery = PhysicsRayQueryParameters3D.Create(GlobalPosition + Vector3.Up*HeadSystem.Position.Y, postDashLocation, GroundDetector.CollisionMask); var wallBehindResult = _spaceState.IntersectRay(wallBehindQuery); var shouldRebound = wallBehindResult.Count > 0;