Compare commits

...

5 Commits

Author SHA1 Message Date
c6559d593a fixed slope ground slide
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 19s
Create tag and build when new code gets to main / Export (push) Successful in 9m32s
2026-01-14 10:21:50 +01:00
e32dac9e6e broken sloped slide
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 20s
Create tag and build when new code gets to main / Export (push) Successful in 9m32s
2026-01-13 23:52:44 +01:00
30b4d1a2eb jumping from slides and some improvement on air gliding 2026-01-13 14:22:26 +01:00
2fa4ce68e7 revamped the dash, fixed an infinite jump issue and fixed buffered inputs
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 20s
Create tag and build when new code gets to main / Export (push) Successful in 10m15s
2026-01-13 11:18:56 +01:00
80e533d98e simple slam and changed wall hugging to only work when input is towards the wall 2026-01-13 09:43:58 +01:00
5 changed files with 485 additions and 72 deletions

View File

@@ -133,6 +133,21 @@ material = ExtResource("3_vvhq3")
transform = Transform3D(5, 0, 0, 0, -2.18557e-07, 5, 0, -5, -2.18557e-07, 1, 0.1, -9.5) transform = Transform3D(5, 0, 0, 0, -2.18557e-07, 5, 0, -5, -2.18557e-07, 1, 0.1, -9.5)
text = "10m" text = "10m"
[node name="Label3D6" type="Label3D" parent="Greybox/RunningTrack"]
transform = Transform3D(5, 0, 0, 0, -2.18557e-07, 5, 0, -5, -2.18557e-07, 27.5, 0.1, 1)
text = "10deg
"
[node name="Label3D7" type="Label3D" parent="Greybox/RunningTrack"]
transform = Transform3D(5, 0, 0, 0, -2.18557e-07, 5, 0, -5, -2.18557e-07, 30.5, 0.1, 1)
text = "20deg
"
[node name="Label3D8" type="Label3D" parent="Greybox/RunningTrack"]
transform = Transform3D(5, 0, 0, 0, -2.18557e-07, 5, 0, -5, -2.18557e-07, 33.5, 0.1, 1)
text = "30deg
"
[node name="Label3D2" type="Label3D" parent="Greybox/RunningTrack"] [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) transform = Transform3D(5, 0, 0, 0, -2.18557e-07, 5, 0, -5, -2.18557e-07, 1, 0.1, -19.5)
text = "20m" text = "20m"
@@ -367,6 +382,60 @@ use_collision = true
size = Vector3(7.5, 20, 10) size = Vector3(7.5, 20, 10)
material = ExtResource("3_vvhq3") material = ExtResource("3_vvhq3")
[node name="CSGBox3D41" type="CSGBox3D" parent="Greybox/JumpHeights"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 22.75, 5, -1.5)
use_collision = true
size = Vector3(12.5, 10, 3)
material = ExtResource("3_vvhq3")
[node name="CSGBox3D47" type="CSGBox3D" parent="Greybox/JumpHeights"]
transform = Transform3D(1, 0, 0, 0, 0.9848078, 0.17364816, 0, -0.17364816, 0.9848078, 22.75, 0.03095889, -30.695885)
use_collision = true
size = Vector3(12.5, 10, 58)
material = ExtResource("3_vvhq3")
[node name="CSGBox3D48" type="CSGBox3D" parent="Greybox/JumpHeights"]
transform = Transform3D(1, 0, 0, 0, 0.9396926, 0.34202012, 0, -0.34202012, 0.9396926, 30.5, 1.5878377, -16.713436)
use_collision = true
size = Vector3(3, 6.5, 31.5)
material = ExtResource("3_vvhq3")
[node name="CSGBox3D49" type="CSGBox3D" parent="Greybox/JumpHeights"]
transform = Transform3D(1, 0, 0, 0, 0.86602545, 0.5, 0, -0.5, 0.86602545, 33.5, 2.5053406, -10.524445)
use_collision = true
size = Vector3(3, 5.5, 20.5)
material = ExtResource("3_vvhq3")
[node name="CSGBox3D42" type="CSGBox3D" parent="Greybox/JumpHeights"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 30.5, 5, -1.5)
use_collision = true
size = Vector3(3, 10, 3)
material = ExtResource("3_vvhq3")
[node name="CSGBox3D43" type="CSGBox3D" parent="Greybox/JumpHeights"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 33.5, 5, -1.5)
use_collision = true
size = Vector3(3, 10, 3)
material = ExtResource("3_vvhq3")
[node name="CSGBox3D44" type="CSGBox3D" parent="Greybox/JumpHeights"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 36.5, 5, -1.5)
use_collision = true
size = Vector3(3, 10, 3)
material = ExtResource("3_vvhq3")
[node name="CSGBox3D45" type="CSGBox3D" parent="Greybox/JumpHeights"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 39.5, 5, -1.5)
use_collision = true
size = Vector3(3, 10, 3)
material = ExtResource("3_vvhq3")
[node name="CSGBox3D46" type="CSGBox3D" parent="Greybox/JumpHeights"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 42.5, 5, -1.5)
use_collision = true
size = Vector3(3, 10, 3)
material = ExtResource("3_vvhq3")
[node name="CSGBox3D34" type="CSGBox3D" parent="Greybox/JumpHeights"] [node name="CSGBox3D34" type="CSGBox3D" parent="Greybox/JumpHeights"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -24.5, 10, -15) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -24.5, 10, -15)
use_collision = true use_collision = true

View File

@@ -59,7 +59,7 @@ height = 1.0
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_6lejt"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_6lejt"]
radius = 1.0 radius = 1.0
height = 3.0 height = 3.5
[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_2q0ik"] [sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_2q0ik"]
blend_mode = 1 blend_mode = 1
@@ -84,16 +84,24 @@ DoubleJumpHangTimeInFrames = 3
DoubleJumpGravityLesseningFactor = 1.5 DoubleJumpGravityLesseningFactor = 1.5
WallJumpStartVelocity = 8.0 WallJumpStartVelocity = 8.0
MaxNumberOfEmpoweredActions = 3 MaxNumberOfEmpoweredActions = 3
SimpleDashStrength = 15.0 SimpleDashStrength = 18.0
SimpleDashTime = 0.2
AimedDashTime = 0.2 AimedDashTime = 0.2
PostDashSpeed = 30.0 PostDashSpeed = 30.0
AccelerationGroundSlide = 0.2 SlamSpeed = 80.0
AirGlideVSpeed = 3.0 FlatGroundSlideSpeedLossRate = 0.996
AccelerationAirGlide = 0.2 GroundSlideJumpMultiplier = 0.1
DecelerationAirGlide = 0.0 GroundSlideJumpSpeedFactor = 0.1
GroundSlideDownSlopeAcceleration = 0.2
GroundSlideDownSlopeMaxSpeed = 30.0
AirGlideVSpeed = 4.0
AccelerationAirGlide = 0.4
AirGlideVerticalAcceleration = 8.0
AirGlideJumpMultiplier = 0.1
AirGlideJumpSpeedFactor = 0.05
WallHugGravityLesseningFactor = 15.0 WallHugGravityLesseningFactor = 15.0
WallHugDownwardMaxSpeed = 8.0 WallHugDownwardMaxSpeed = 4.0
WallHugHorizontalDeceleration = 0.5 WallHugHorizontalDeceleration = 1.0
[node name="WallRunSnapper" type="RayCast3D" parent="."] [node name="WallRunSnapper" type="RayCast3D" parent="."]
unique_name_in_owner = true unique_name_in_owner = true
@@ -241,7 +249,10 @@ mesh = SubResource("CylinderMesh_nodcl")
[node name="GroundDetector" type="ShapeCast3D" parent="."] [node name="GroundDetector" type="ShapeCast3D" parent="."]
shape = SubResource("CapsuleShape3D_6lejt") shape = SubResource("CapsuleShape3D_6lejt")
target_position = Vector3(0, -0.5, 0) collision_mask = 2
[node name="DirectGroundDetector" type="RayCast3D" parent="."]
target_position = Vector3(0, -2, 0)
collision_mask = 2 collision_mask = 2
[node name="DashCooldown" type="Timer" parent="."] [node name="DashCooldown" type="Timer" parent="."]
@@ -526,16 +537,19 @@ to = NodePath("../../OnWall/Hugging")
event = &"on_wall" event = &"on_wall"
delay_in_seconds = "0.0" delay_in_seconds = "0.0"
[node name="Slamming" type="Node" parent="StateChart/Root/Movement"]
script = ExtResource("27_34snm")
[node name="OnSlamEnded" type="Node" parent="StateChart/Root/Movement/Slamming"]
script = ExtResource("28_n7qhm")
to = NodePath("../../Grounded")
event = &"grounded"
delay_in_seconds = "0.0"
[node name="Jump" type="Node" parent="StateChart/Root/Movement"] [node name="Jump" type="Node" parent="StateChart/Root/Movement"]
script = ExtResource("26_infe6") script = ExtResource("26_infe6")
initial_state = NodePath("SimpleJump") initial_state = NodePath("SimpleJump")
[node name="OnSlide" type="Node" parent="StateChart/Root/Movement/Jump"]
script = ExtResource("28_n7qhm")
to = NodePath("../../Sliding/AirGlide")
event = &"slide"
delay_in_seconds = "0.0"
[node name="OnMantle" type="Node" parent="StateChart/Root/Movement/Jump"] [node name="OnMantle" type="Node" parent="StateChart/Root/Movement/Jump"]
script = ExtResource("28_n7qhm") script = ExtResource("28_n7qhm")
to = NodePath("../../Mantling") to = NodePath("../../Mantling")
@@ -551,6 +565,12 @@ to = NodePath("../../../Airborne/DoubleJumpEnabled")
event = &"jump_ended" event = &"jump_ended"
delay_in_seconds = "0.0" delay_in_seconds = "0.0"
[node name="OnSlide" type="Node" parent="StateChart/Root/Movement/Jump/SimpleJump"]
script = ExtResource("28_n7qhm")
to = NodePath("../../../Sliding/AirGlideDoubleJumpEnabled")
event = &"slide"
delay_in_seconds = "0.0"
[node name="DoubleJump" type="Node" parent="StateChart/Root/Movement/Jump"] [node name="DoubleJump" type="Node" parent="StateChart/Root/Movement/Jump"]
script = ExtResource("27_34snm") script = ExtResource("27_34snm")
@@ -560,6 +580,12 @@ to = NodePath("../../../Airborne/Falling")
event = &"jump_ended" event = &"jump_ended"
delay_in_seconds = "0.0" delay_in_seconds = "0.0"
[node name="OnSlide" type="Node" parent="StateChart/Root/Movement/Jump/DoubleJump"]
script = ExtResource("28_n7qhm")
to = NodePath("../../../Sliding/AirGlide")
event = &"slide"
delay_in_seconds = "0.0"
[node name="Dashing" type="Node" parent="StateChart/Root/Movement"] [node name="Dashing" type="Node" parent="StateChart/Root/Movement"]
script = ExtResource("26_infe6") script = ExtResource("26_infe6")
initial_state = NodePath("Dash") initial_state = NodePath("Dash")
@@ -592,6 +618,12 @@ script = ExtResource("27_34snm")
script = ExtResource("26_infe6") script = ExtResource("26_infe6")
initial_state = NodePath("GroundSlide") initial_state = NodePath("GroundSlide")
[node name="OnDash" type="Node" parent="StateChart/Root/Movement/Sliding"]
script = ExtResource("28_n7qhm")
to = NodePath("../../Dashing/Dash")
event = &"actually_no_dash"
delay_in_seconds = "0.0"
[node name="OnMantle" type="Node" parent="StateChart/Root/Movement/Sliding"] [node name="OnMantle" type="Node" parent="StateChart/Root/Movement/Sliding"]
script = ExtResource("28_n7qhm") script = ExtResource("28_n7qhm")
to = NodePath("../../Mantling") to = NodePath("../../Mantling")
@@ -609,10 +641,43 @@ delay_in_seconds = "0.0"
[node name="OnAirborne" type="Node" parent="StateChart/Root/Movement/Sliding/GroundSlide"] [node name="OnAirborne" type="Node" parent="StateChart/Root/Movement/Sliding/GroundSlide"]
script = ExtResource("28_n7qhm") script = ExtResource("28_n7qhm")
to = NodePath("../../AirGlide") to = NodePath("../../AirGlideDoubleJumpEnabled")
event = &"start_falling" event = &"start_falling"
delay_in_seconds = "0.0" delay_in_seconds = "0.0"
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/Sliding/GroundSlide"]
script = ExtResource("28_n7qhm")
to = NodePath("../../../Jump/SimpleJump")
event = &"jump"
delay_in_seconds = "0.0"
[node name="OnCancel" type="Node" parent="StateChart/Root/Movement/Sliding/GroundSlide"]
script = ExtResource("28_n7qhm")
to = NodePath("../../SlideCanceled")
event = &"slide_canceled"
delay_in_seconds = "0.0"
[node name="AirGlideDoubleJumpEnabled" type="Node" parent="StateChart/Root/Movement/Sliding"]
script = ExtResource("27_34snm")
[node name="OnSlideReleased" type="Node" parent="StateChart/Root/Movement/Sliding/AirGlideDoubleJumpEnabled"]
script = ExtResource("28_n7qhm")
to = NodePath("../../../Airborne/Reset")
event = &"slide_released"
delay_in_seconds = "0.0"
[node name="OnGrounded" type="Node" parent="StateChart/Root/Movement/Sliding/AirGlideDoubleJumpEnabled"]
script = ExtResource("28_n7qhm")
to = NodePath("../../GroundSlide")
event = &"grounded"
delay_in_seconds = "0.0"
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/Sliding/AirGlideDoubleJumpEnabled"]
script = ExtResource("28_n7qhm")
to = NodePath("../../../Jump/DoubleJump")
event = &"jump"
delay_in_seconds = "0.0"
[node name="AirGlide" type="Node" parent="StateChart/Root/Movement/Sliding"] [node name="AirGlide" type="Node" parent="StateChart/Root/Movement/Sliding"]
script = ExtResource("27_34snm") script = ExtResource("27_34snm")
@@ -628,6 +693,33 @@ to = NodePath("../../GroundSlide")
event = &"grounded" event = &"grounded"
delay_in_seconds = "0.0" delay_in_seconds = "0.0"
[node name="SlideCanceled" type="Node" parent="StateChart/Root/Movement/Sliding"]
script = ExtResource("27_34snm")
[node name="OnAirborne" type="Node" parent="StateChart/Root/Movement/Sliding/SlideCanceled"]
script = ExtResource("28_n7qhm")
to = NodePath("../../../Airborne/CoyoteEnabled")
event = &"start_falling"
delay_in_seconds = "0.0"
[node name="OnDash" type="Node" parent="StateChart/Root/Movement/Sliding/SlideCanceled"]
script = ExtResource("28_n7qhm")
to = NodePath("../../../Dashing/Dash")
event = &"dash"
delay_in_seconds = "0.0"
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/Sliding/SlideCanceled"]
script = ExtResource("28_n7qhm")
to = NodePath("../../../Jump/SimpleJump")
event = &"jump"
delay_in_seconds = "0.0"
[node name="OnSlideReleased" type="Node" parent="StateChart/Root/Movement/Sliding/SlideCanceled"]
script = ExtResource("28_n7qhm")
to = NodePath("../../../Grounded")
event = &"slide_released"
delay_in_seconds = "0.0"
[node name="Airborne" type="Node" parent="StateChart/Root/Movement"] [node name="Airborne" type="Node" parent="StateChart/Root/Movement"]
script = ExtResource("26_infe6") script = ExtResource("26_infe6")
initial_state = NodePath("CoyoteEnabled") initial_state = NodePath("CoyoteEnabled")
@@ -654,15 +746,21 @@ to = NodePath("../../Grounded")
event = &"grounded" event = &"grounded"
delay_in_seconds = "0.0" delay_in_seconds = "0.0"
[node name="OnSlide" type="Node" parent="StateChart/Root/Movement/Airborne"] [node name="OnSlam" type="Node" parent="StateChart/Root/Movement/Airborne"]
script = ExtResource("28_n7qhm") script = ExtResource("28_n7qhm")
to = NodePath("../../Sliding/AirGlide") to = NodePath("../../Slamming")
event = &"slide" event = &"slam"
delay_in_seconds = "0.0" delay_in_seconds = "0.0"
[node name="CoyoteEnabled" type="Node" parent="StateChart/Root/Movement/Airborne"] [node name="CoyoteEnabled" type="Node" parent="StateChart/Root/Movement/Airborne"]
script = ExtResource("27_34snm") script = ExtResource("27_34snm")
[node name="OnSlide" type="Node" parent="StateChart/Root/Movement/Airborne/CoyoteEnabled"]
script = ExtResource("28_n7qhm")
to = NodePath("../../../Sliding/AirGlideDoubleJumpEnabled")
event = &"slide"
delay_in_seconds = "0.0"
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/Airborne/CoyoteEnabled"] [node name="OnJump" type="Node" parent="StateChart/Root/Movement/Airborne/CoyoteEnabled"]
script = ExtResource("28_n7qhm") script = ExtResource("28_n7qhm")
to = NodePath("../../../Jump/SimpleJump") to = NodePath("../../../Jump/SimpleJump")
@@ -678,6 +776,12 @@ delay_in_seconds = "0.0"
[node name="DoubleJumpEnabled" type="Node" parent="StateChart/Root/Movement/Airborne"] [node name="DoubleJumpEnabled" type="Node" parent="StateChart/Root/Movement/Airborne"]
script = ExtResource("27_34snm") script = ExtResource("27_34snm")
[node name="OnSlide" type="Node" parent="StateChart/Root/Movement/Airborne/DoubleJumpEnabled"]
script = ExtResource("28_n7qhm")
to = NodePath("../../../Sliding/AirGlideDoubleJumpEnabled")
event = &"slide"
delay_in_seconds = "0.0"
[node name="OnWallHug" type="Node" parent="StateChart/Root/Movement/Airborne/DoubleJumpEnabled"] [node name="OnWallHug" type="Node" parent="StateChart/Root/Movement/Airborne/DoubleJumpEnabled"]
script = ExtResource("28_n7qhm") script = ExtResource("28_n7qhm")
to = NodePath("../../../OnWall/Hugging") to = NodePath("../../../OnWall/Hugging")
@@ -693,6 +797,12 @@ delay_in_seconds = "0.0"
[node name="Falling" type="Node" parent="StateChart/Root/Movement/Airborne"] [node name="Falling" type="Node" parent="StateChart/Root/Movement/Airborne"]
script = ExtResource("27_34snm") script = ExtResource("27_34snm")
[node name="OnSlide" type="Node" parent="StateChart/Root/Movement/Airborne/Falling"]
script = ExtResource("28_n7qhm")
to = NodePath("../../../Sliding/AirGlide")
event = &"slide"
delay_in_seconds = "0.0"
[node name="OnWallHug" type="Node" parent="StateChart/Root/Movement/Airborne/Falling"] [node name="OnWallHug" type="Node" parent="StateChart/Root/Movement/Airborne/Falling"]
script = ExtResource("28_n7qhm") script = ExtResource("28_n7qhm")
to = NodePath("../../../OnWall/Hugging") to = NodePath("../../../OnWall/Hugging")
@@ -705,6 +815,12 @@ to = NodePath("../../DoubleJumpEnabled")
event = &"enable_double_jump" event = &"enable_double_jump"
delay_in_seconds = "0.0" delay_in_seconds = "0.0"
[node name="OnWallJump" type="Node" parent="StateChart/Root/Movement/Airborne/Falling"]
script = ExtResource("28_n7qhm")
to = NodePath("../../../Jump/DoubleJump")
event = &"wall_jump"
delay_in_seconds = "0.0"
[node name="OnWall" type="Node" parent="StateChart/Root/Movement"] [node name="OnWall" type="Node" parent="StateChart/Root/Movement"]
script = ExtResource("26_infe6") script = ExtResource("26_infe6")
initial_state = NodePath("Hugging") initial_state = NodePath("Hugging")

View File

@@ -49,6 +49,7 @@ public partial class PlayerController : CharacterBody3D
public CylinderMesh DashIndicatorMeshCylinder; public CylinderMesh DashIndicatorMeshCylinder;
public RayCast3D WallRunSnapper; public RayCast3D WallRunSnapper;
public ShapeCast3D GroundDetector; public ShapeCast3D GroundDetector;
public RayCast3D DirectGroundDetector;
// Inspector stuff // Inspector stuff
[Export] public Marker3D TutorialWeaponTarget; [Export] public Marker3D TutorialWeaponTarget;
@@ -118,8 +119,10 @@ public partial class PlayerController : CharacterBody3D
public int MaxNumberOfEmpoweredActions { get; set; } = 1; public int MaxNumberOfEmpoweredActions { get; set; } = 1;
// Simple dash // Simple dash
[ExportSubgroup("Simple")] [ExportSubgroup("Simple")]
[Export(PropertyHint.Range, "0,50,0.1")] [Export(PropertyHint.Range, "0,50,0.1,or_greater")]
public float SimpleDashStrength { get; set; } = 10f; public float SimpleDashStrength { get; set; } = 10f;
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
public float SimpleDashTime { get; set; } = 0.5f;
// Aimed Dash // Aimed Dash
[ExportSubgroup("Special")] [ExportSubgroup("Special")]
[Export(PropertyHint.Range, "0,1,0.01,or_greater")] [Export(PropertyHint.Range, "0,1,0.01,or_greater")]
@@ -128,6 +131,10 @@ public partial class PlayerController : CharacterBody3D
public float PostDashSpeed { get; set; } = 100f; public float PostDashSpeed { get; set; } = 100f;
[Export(PropertyHint.Range, "0,1,0.01,or_greater")] [Export(PropertyHint.Range, "0,1,0.01,or_greater")]
public float TimeScaleAimInAir { get; set; } = 0.05f; public float TimeScaleAimInAir { get; set; } = 0.05f;
// Slam
[ExportSubgroup("Slam")]
[Export(PropertyHint.Range, "0,100,1,or_greater")]
public float SlamSpeed { get; set; } = 50.0f;
// Sliding and gliding // Sliding and gliding
[ExportGroup("Slide")] [ExportGroup("Slide")]
@@ -136,14 +143,36 @@ public partial class PlayerController : CharacterBody3D
public float AccelerationGroundSlide = 1.0f; public float AccelerationGroundSlide = 1.0f;
[Export(PropertyHint.Range, "0,1,0.01,or_greater")] [Export(PropertyHint.Range, "0,1,0.01,or_greater")]
public float DecelerationGroundSlide = 0.1f; public float DecelerationGroundSlide = 0.1f;
[Export(PropertyHint.Range, "0.99,1,0.0001")]
public float FlatGroundSlideSpeedLossRate = 0.9975f;
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
public float GroundSlideJumpMultiplier = 1.0f;
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
public float GroundSlideJumpSpeedFactor;
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
public float GroundSlideDownSlopeAcceleration = 0.1f;
[Export(PropertyHint.Range, "0,100,0.1,or_greater")]
public float GroundSlideDownSlopeMaxSpeed = 50f;
[Export(PropertyHint.Range, "1,10,0.1,or_greater")]
public float GroundSlideSlopeMagnetism = 2f;
[ExportSubgroup("Air glide")] [ExportSubgroup("Air glide")]
[Export]
public bool AllowForVelocityRedirection = true;
[Export(PropertyHint.Range, "0,10,0.01,or_greater")] [Export(PropertyHint.Range, "0,10,0.01,or_greater")]
public float AirGlideVSpeed { get; set; } = 1.0f; public float AirGlideVSpeed { get; set; } = 1.0f;
[Export(PropertyHint.Range, "0,1,0.01,or_greater")] [Export(PropertyHint.Range, "0,1,0.01,or_greater")]
public float AccelerationAirGlide = 1.0f; public float AccelerationAirGlide = 1.0f;
[Export(PropertyHint.Range, "0,1,0.01,or_greater")] [Export(PropertyHint.Range, "0,1,0.01,or_greater")]
public float DecelerationAirGlide = 0.1f; public float DecelerationAirGlide = 0.1f;
[Export(PropertyHint.Range, "0,10,0.01,or_greater")]
public float AirGlideVerticalAcceleration = 1.0f;
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
public float AirGlideJumpMultiplier = 1.0f;
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
public float AirGlideJumpSpeedFactor;
// Wall hug // Wall hug
[ExportGroup("Wall hug")] [ExportGroup("Wall hug")]
@@ -246,6 +275,7 @@ public partial class PlayerController : CharacterBody3D
private StateChartState _grounded; private StateChartState _grounded;
private StateChartState _airborne; private StateChartState _airborne;
private StateChartState _coyoteEnabled; private StateChartState _coyoteEnabled;
private StateChartState _jumping;
private StateChartState _simpleJump; private StateChartState _simpleJump;
private StateChartState _doubleJump; private StateChartState _doubleJump;
private StateChartState _mantling; private StateChartState _mantling;
@@ -254,13 +284,20 @@ public partial class PlayerController : CharacterBody3D
private StateChartState _sliding; private StateChartState _sliding;
private StateChartState _groundSliding; private StateChartState _groundSliding;
private StateChartState _airGliding; private StateChartState _airGliding;
private StateChartState _airGlidingDoubleJump;
private StateChartState _slideCanceled;
private StateChartState _slamming;
private StateChartState _onWall; private StateChartState _onWall;
private StateChartState _onWallHugging; private StateChartState _onWallHugging;
private StateChartState _onWallHanging; private StateChartState _onWallHanging;
private StateChartState _onWallRunning; private StateChartState _onWallRunning;
private Transition _onJumpFromWall; private Transition _onJumpFromWall;
private Transition _onJumpFromWallFalling;
private Transition _onLeaveWallFromRun; private Transition _onLeaveWallFromRun;
private Transition _onGroundSlideJump;
private Transition _onAirGlideDoubleJump;
public override void _Ready() public override void _Ready()
{ {
@@ -299,6 +336,7 @@ public partial class PlayerController : CharacterBody3D
WallHugSystem = GetNode<WallHugSystem>("WallHugSystem"); WallHugSystem = GetNode<WallHugSystem>("WallHugSystem");
WallRunSnapper = GetNode<RayCast3D>("%WallRunSnapper"); WallRunSnapper = GetNode<RayCast3D>("%WallRunSnapper");
GroundDetector = GetNode<ShapeCast3D>("GroundDetector"); GroundDetector = GetNode<ShapeCast3D>("GroundDetector");
DirectGroundDetector = GetNode<RayCast3D>("DirectGroundDetector");
RayCast3D stairsBelowRayCast3D = GetNode<RayCast3D>("StairsBelowRayCast3D"); RayCast3D stairsBelowRayCast3D = GetNode<RayCast3D>("StairsBelowRayCast3D");
RayCast3D stairsAheadRayCast3D = GetNode<RayCast3D>("StairsAheadRayCast3D"); RayCast3D stairsAheadRayCast3D = GetNode<RayCast3D>("StairsAheadRayCast3D");
_headCollisionDetectors = new RayCast3D[NUM_OF_HEAD_COLLISION_DETECTORS]; _headCollisionDetectors = new RayCast3D[NUM_OF_HEAD_COLLISION_DETECTORS];
@@ -318,10 +356,15 @@ public partial class PlayerController : CharacterBody3D
_aiming = StateChartState.Of(GetNode("StateChart/Root/Aim/On")); _aiming = StateChartState.Of(GetNode("StateChart/Root/Aim/On"));
_simpleDash = StateChartState.Of(GetNode("StateChart/Root/Movement/Dashing/Dash")); _simpleDash = StateChartState.Of(GetNode("StateChart/Root/Movement/Dashing/Dash"));
_aimedDash = StateChartState.Of(GetNode("StateChart/Root/Movement/Dashing/AimedDash")); _aimedDash = StateChartState.Of(GetNode("StateChart/Root/Movement/Dashing/AimedDash"));
_slamming = StateChartState.Of(GetNode("StateChart/Root/Movement/Slamming"));
_sliding = StateChartState.Of(GetNode("StateChart/Root/Movement/Sliding")); _sliding = StateChartState.Of(GetNode("StateChart/Root/Movement/Sliding"));
_slideCanceled = StateChartState.Of(GetNode("StateChart/Root/Movement/Sliding/SlideCanceled"));
_groundSliding = StateChartState.Of(GetNode("StateChart/Root/Movement/Sliding/GroundSlide")); _groundSliding = StateChartState.Of(GetNode("StateChart/Root/Movement/Sliding/GroundSlide"));
_airGliding = StateChartState.Of(GetNode("StateChart/Root/Movement/Sliding/AirGlide")); _airGliding = StateChartState.Of(GetNode("StateChart/Root/Movement/Sliding/AirGlide"));
_airGlidingDoubleJump = StateChartState.Of(GetNode("StateChart/Root/Movement/Sliding/AirGlideDoubleJumpEnabled"));
_onGroundSlideJump = Transition.Of(GetNode("StateChart/Root/Movement/Sliding/GroundSlide/OnJump"));
_onAirGlideDoubleJump = Transition.Of(GetNode("StateChart/Root/Movement/Sliding/AirGlideDoubleJumpEnabled/OnJump"));
// _actionHanging = StateChartState.Of(GetNode("StateChart/Root/Actions/Hanging")); // _actionHanging = StateChartState.Of(GetNode("StateChart/Root/Actions/Hanging"));
_powerExpired = StateChartState.Of(GetNode("StateChart/Root/PowerReserve/Expired")); _powerExpired = StateChartState.Of(GetNode("StateChart/Root/PowerReserve/Expired"));
@@ -332,10 +375,12 @@ public partial class PlayerController : CharacterBody3D
_airborne = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne")); _airborne = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne"));
_coyoteEnabled = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/CoyoteEnabled")); _coyoteEnabled = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/CoyoteEnabled"));
// _doubleJumpEnabled = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/DoubleJumpEnabled")); // _doubleJumpEnabled = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/DoubleJumpEnabled"));
_jumping = StateChartState.Of(GetNode("StateChart/Root/Movement/Jump"));
_simpleJump = StateChartState.Of(GetNode("StateChart/Root/Movement/Jump/SimpleJump")); _simpleJump = StateChartState.Of(GetNode("StateChart/Root/Movement/Jump/SimpleJump"));
_doubleJump = StateChartState.Of(GetNode("StateChart/Root/Movement/Jump/DoubleJump")); _doubleJump = StateChartState.Of(GetNode("StateChart/Root/Movement/Jump/DoubleJump"));
_mantling = StateChartState.Of(GetNode("StateChart/Root/Movement/Mantling")); _mantling = StateChartState.Of(GetNode("StateChart/Root/Movement/Mantling"));
_onJumpFromWall = Transition.Of(GetNode("StateChart/Root/Movement/OnWall/OnJump")); _onJumpFromWall = Transition.Of(GetNode("StateChart/Root/Movement/OnWall/OnJump"));
_onJumpFromWallFalling = Transition.Of(GetNode("StateChart/Root/Movement/Airborne/Falling/OnWallJump"));
_onWall = StateChartState.Of(GetNode("StateChart/Root/Movement/OnWall")); _onWall = StateChartState.Of(GetNode("StateChart/Root/Movement/OnWall"));
_onWallHugging = StateChartState.Of(GetNode("StateChart/Root/Movement/OnWall/Hugging")); _onWallHugging = StateChartState.Of(GetNode("StateChart/Root/Movement/OnWall/Hugging"));
_onWallHanging = StateChartState.Of(GetNode("StateChart/Root/Movement/OnWall/Hanging")); _onWallHanging = StateChartState.Of(GetNode("StateChart/Root/Movement/OnWall/Hanging"));
@@ -411,8 +456,18 @@ public partial class PlayerController : CharacterBody3D
_sliding.StateEntered += SlideStarted; _sliding.StateEntered += SlideStarted;
_sliding.StateExited += SlideEnded; _sliding.StateExited += SlideEnded;
_slideCanceled.StateEntered += OnSlideCanceled;
_slideCanceled.StatePhysicsProcessing += HandleSlideCanceled;
_groundSliding.StatePhysicsProcessing += HandleGroundSlide; _groundSliding.StatePhysicsProcessing += HandleGroundSlide;
_airGliding.StatePhysicsProcessing += HandleAirGlide; _airGliding.StatePhysicsProcessing += HandleAirGlide;
_airGlidingDoubleJump.StatePhysicsProcessing += HandleAirGlide;
_onGroundSlideJump.Taken += JumpFromGroundSlide;
_onAirGlideDoubleJump.Taken += JumpFromAirGlide;
_slamming.StateEntered += SlamStarted;
_slamming.StateExited += SlamEnded;
_slamming.StatePhysicsProcessing += HandleSlam;
_simpleDashCooldownTimer.Timeout += DashCooldownTimeout; _simpleDashCooldownTimer.Timeout += DashCooldownTimeout;
_airborneDashCooldownTimer.Timeout += AirborneDashCooldownTimeout; _airborneDashCooldownTimer.Timeout += AirborneDashCooldownTimeout;
@@ -424,6 +479,7 @@ public partial class PlayerController : CharacterBody3D
_onWallRunning.StatePhysicsProcessing += HandleWallRunning; _onWallRunning.StatePhysicsProcessing += HandleWallRunning;
_onJumpFromWall.Taken += OnJumpFromWall; _onJumpFromWall.Taken += OnJumpFromWall;
_onJumpFromWallFalling.Taken += OnJumpFromWall;
_onLeaveWallFromRun.Taken += OnLeaveWallFromRun; _onLeaveWallFromRun.Taken += OnLeaveWallFromRun;
} }
@@ -478,6 +534,7 @@ public partial class PlayerController : CharacterBody3D
/////////////////////////// ///////////////////////////
// Grounded management // // Grounded management //
/////////////////////////// ///////////////////////////
public void OnGrounded() public void OnGrounded()
{ {
_isWallJumpAvailable = true; _isWallJumpAvailable = true;
@@ -486,28 +543,36 @@ public partial class PlayerController : CharacterBody3D
if (_simpleDashCooldownTimer.IsStopped()) if (_simpleDashCooldownTimer.IsStopped())
_simpleDashCooldownTimer.Start(); _simpleDashCooldownTimer.Start();
if (_bufferedAction == BufferedActions.Jump && _currentInputBufferFrames > 0)
{
_currentInputBufferFrames = 0;
PerformJump();
}
if (_bufferedAction == BufferedActions.Dash && _currentInputBufferFrames > 0)
{
_currentInputBufferFrames = 0;
SimpleDash();
}
if (_bufferedAction == BufferedActions.MantleJump) if (_bufferedAction == BufferedActions.MantleJump)
{ {
SimpleDash(); _playerState.SendEvent("jump");
OnJumpStarted(MantleJumpStartVelocity);
} }
if (_bufferedAction == BufferedActions.MantleDash) if (_bufferedAction == BufferedActions.MantleDash)
{ {
SimpleDash(MantleDashStrength); if (GetMoveInput().Length() < Mathf.Epsilon)
{
_bufferedAction = BufferedActions.None;
return;
}
_playerState.SendEvent("dash");
}
if (_bufferedAction == BufferedActions.Jump && _currentInputBufferFrames > 0)
{
_currentInputBufferFrames = 0;
_playerState.SendEvent("jump");
}
if (_bufferedAction == BufferedActions.Dash && _currentInputBufferFrames > 0)
{
if (GetMoveInput().Length() < Mathf.Epsilon)
{
_bufferedAction = BufferedActions.None;
return;
}
_currentInputBufferFrames = 0;
_playerState.SendEvent("dash");
} }
_bufferedAction = BufferedActions.None;
} }
public bool IsGroundLike() public bool IsGroundLike()
@@ -528,7 +593,7 @@ public partial class PlayerController : CharacterBody3D
Velocity = new Vector3(horizontalVelocity.X, Velocity.Y, horizontalVelocity.Z); Velocity = new Vector3(horizontalVelocity.X, Velocity.Y, horizontalVelocity.Z);
} }
private void HandleStairs(float delta) private void MoveSlideAndHandleStairs(float delta)
{ {
StairsSystem.UpStairsCheckParams upStairsCheckParams = new StairsSystem.UpStairsCheckParams StairsSystem.UpStairsCheckParams upStairsCheckParams = new StairsSystem.UpStairsCheckParams
{ {
@@ -545,7 +610,7 @@ public partial class PlayerController : CharacterBody3D
}; };
StairsSystem.UpStairsCheckResult upStairsCheckResult = StairsSystem.SnapUpStairsCheck(upStairsCheckParams); StairsSystem.UpStairsCheckResult upStairsCheckResult = StairsSystem.SnapUpStairsCheck(upStairsCheckParams);
if (upStairsCheckResult.UpdateRequired) if (upStairsCheckResult.UpdateRequired && !_jumping.Active)
{ {
upStairsCheckResult.Update(this); upStairsCheckResult.Update(this);
} }
@@ -638,7 +703,7 @@ public partial class PlayerController : CharacterBody3D
} }
// If all else fail and we go down, we hug // If all else fail and we go down, we hug
if (Velocity.Y < 0 && !_coyoteEnabled.Active) if (Velocity.Y < 0 && IsInputTowardsWall(wallNormal))
{ {
_playerState.SendEvent("wall_hug"); _playerState.SendEvent("wall_hug");
} }
@@ -839,22 +904,28 @@ public partial class PlayerController : CharacterBody3D
_playerState.SendEvent("cancel_aim"); _playerState.SendEvent("cancel_aim");
return; return;
} }
if (GetMoveInput().Length() < Mathf.Epsilon) return;
// Buffer dash in case of mantle or inputting dash airborne before touching the ground without air dash available
_currentInputBufferFrames = InputBufferFrames;
_bufferedAction = _mantling.Active ? BufferedActions.MantleDash : BufferedActions.Dash;
if (_airborne.Active) if (_airborne.Active)
{ {
if (!_canDashAirborne) if (!_canDashAirborne)
return; return;
_canDashAirborne = false; _canDashAirborne = false;
} }
_currentInputBufferFrames = InputBufferFrames;
_bufferedAction = _mantling.Active ? BufferedActions.MantleDash : BufferedActions.Dash;
_playerState.SendEvent("dash"); _playerState.SendEvent("dash");
} }
public void SimpleDashInDirection(Vector3 direction, float strength = -1) public void SimpleDashInDirection(Vector3 direction, float strength = -1)
{ {
if (strength < 0) strength = SimpleDashStrength; if (strength < 0) strength = SimpleDashStrength;
SetVelocity(direction * strength); SetVelocity(direction * strength);
GetTree().CreateTimer(SimpleDashTime).Timeout += SimpleDashFinished;
} }
public void SimpleDash(float strength = -1) public void SimpleDash(float strength = -1)
{ {
@@ -863,12 +934,32 @@ public partial class PlayerController : CharacterBody3D
public void OnSimpleDashStarted() public void OnSimpleDashStarted()
{ {
if (!_canDash) if (_bufferedAction == BufferedActions.MantleDash)
{
SimpleDash(MantleDashStrength);
_bufferedAction = BufferedActions.None;
return; return;
}
if (!_canDash)
{
_playerState.SendEvent("dash_finished");
return;
}
_canDash = false; _canDash = false;
SimpleDash(); SimpleDash();
_bufferedAction = BufferedActions.None;
} }
public void HandleSimpleDash(float delta) public void HandleSimpleDash(float delta)
{
if (MantleSystem.IsMantlePossible && IsPlayerInputtingForward())
{
_bufferedAction = BufferedActions.MantleDash;
_playerState.SendEvent("mantle");
}
}
public void SimpleDashFinished()
{ {
_playerState.SendEvent("dash_finished"); _playerState.SendEvent("dash_finished");
} }
@@ -876,6 +967,11 @@ public partial class PlayerController : CharacterBody3D
/////////////////////////// ///////////////////////////
// On wall management // // On wall management //
/////////////////////////// ///////////////////////////
public bool IsInputTowardsWall(Vector3 wallNormal)
{
return wallNormal.Dot(GetInputGlobalHDirection()) < -0.5;
}
public void HandleOnWall(float delta) public void HandleOnWall(float delta)
{ {
if (IsTryingToMantle()) _playerState.SendEvent("mantle"); if (IsTryingToMantle()) _playerState.SendEvent("mantle");
@@ -914,10 +1010,8 @@ public partial class PlayerController : CharacterBody3D
WallHug(delta); WallHug(delta);
if (isOnFloorCustom()) if (isOnFloorCustom())
_playerState.SendEvent("grounded"); _playerState.SendEvent("grounded");
if (!WallHugSystem.IsWallHugging()) if (!WallHugSystem.IsWallHugging() || !IsInputTowardsWall(_wallHugStartNormal))
{
_playerState.SendEvent("start_falling"); _playerState.SendEvent("start_falling");
}
} }
public void HandleWallHanging(float delta) public void HandleWallHanging(float delta)
{ {
@@ -980,7 +1074,9 @@ public partial class PlayerController : CharacterBody3D
public void OnInputJumpStarted() public void OnInputJumpStarted()
{ {
_currentInputBufferFrames = InputBufferFrames; _currentInputBufferFrames = InputBufferFrames;
_bufferedAction = _mantling.Active ? BufferedActions.MantleJump : BufferedActions.Jump; if (_mantling.Active) _bufferedAction = BufferedActions.MantleJump;
// Don't overwrite mantle jump buffered action
else if (_bufferedAction == BufferedActions.None) _bufferedAction = BufferedActions.Jump;
_isJumpInputPressed = true; _isJumpInputPressed = true;
PerformJump(); PerformJump();
@@ -996,29 +1092,46 @@ public partial class PlayerController : CharacterBody3D
public void PerformJump() public void PerformJump()
{ {
if (MantleSystem.IsMantlePossible) if (MantleSystem.IsMantlePossible && !_mantling.Active)
{ {
_playerState.SendEvent("mantle"); _playerState.SendEvent("mantle");
return; return;
} }
if (WallHugSystem.IsWallHugging())
{
_playerState.SendEvent("wall_jump");
}
_playerState.SendEvent("jump"); _playerState.SendEvent("jump");
} }
private float _jumpStrengthMultiplier = 1.0f;
public void OnJumpStarted(float verticalVelocity) public void OnJumpStarted(float verticalVelocity)
{ {
_framesSinceJumpAtApex = 0; _framesSinceJumpAtApex = 0;
SetVerticalVelocity(verticalVelocity); var angle = GetFloorAngle();
var floorAngleFactor = angle > 1 ? 1 : 1 + angle;
SetVerticalVelocity(verticalVelocity*_jumpStrengthMultiplier*floorAngleFactor);
_jumpStrengthMultiplier = 1.0f;
} }
public void OnSimpleJumpStarted() public void OnSimpleJumpStarted()
{ {
if (_bufferedAction == BufferedActions.MantleJump)
{
SetVelocity(GetInputGlobalHDirection()*SimpleDashStrength);
OnJumpStarted(MantleJumpStartVelocity);
_bufferedAction = BufferedActions.None;
return;
}
OnJumpStarted(SimpleJumpStartVelocity); OnJumpStarted(SimpleJumpStartVelocity);
_bufferedAction = BufferedActions.None;
} }
public void OnDoubleJumpStarted() public void OnDoubleJumpStarted()
{ {
_canDash = true; _canDash = true;
// _canDashAirborne = true; // _canDashAirborne = true;
OnJumpStarted(DoubleJumpStartVelocity); OnJumpStarted(DoubleJumpStartVelocity);
_bufferedAction = BufferedActions.None;
} }
public void HandleJump(float delta, float gravityFactor, int hangFrames) public void HandleJump(float delta, float gravityFactor, int hangFrames)
@@ -1133,7 +1246,7 @@ public partial class PlayerController : CharacterBody3D
var positionDifference = GlobalPosition - _mantleStartPosition; var positionDifference = GlobalPosition - _mantleStartPosition;
var directionHorizontal = new Vector3(positionDifference.X, 0, positionDifference.Z); var directionHorizontal = new Vector3(positionDifference.X, 0, positionDifference.Z);
// SimpleDashInDirection(directionHorizontal.Normalized()); // SimpleDashInDirection(directionHorizontal.Normalized());
SetVelocity(directionHorizontal.Normalized() * WalkSpeed); SetVelocity(directionHorizontal.Normalized() * _velocityOnMantleStarted.Length());
} }
_customMantle = false; _customMantle = false;
@@ -1152,33 +1265,123 @@ public partial class PlayerController : CharacterBody3D
_playerState.SendEvent("slide_released"); _playerState.SendEvent("slide_released");
} }
public record SlopeRecord(
Vector3 Position,
Vector3 Normal,
Vector3 Direction,
float AngleRadians
);
public Vector3 GetGroundPosition()
{
return DirectGroundDetector.GetCollisionPoint();
}
public Vector3 GetGroundNormal()
{
return DirectGroundDetector.GetCollisionNormal();
}
public SlopeRecord GetSlope()
{
var position = GetGroundPosition();
var normal = GetGroundNormal();
var angle = normal.AngleTo(Vector3.Up);
var vectorInPlane = normal.Cross(Vector3.Up).Normalized();
var direction = normal.Cross(vectorInPlane).Normalized();
return new SlopeRecord(position, normal, direction, angle);
}
public void SlideStarted() public void SlideStarted()
{ {
_targetSpeed = Velocity.Length(); _targetSpeed = Velocity.Length();
} }
public void SlideOnGround(float delta) public void SlideOnGround(float delta)
{ {
// Store current velocity
var currentVelocity = Velocity.Length();
var finalSpeed = currentVelocity * FlatGroundSlideSpeedLossRate;
// Going down slope?
var (position, normal, slopeDirection, slopeAngleRadians) = GetSlope();
// Change velocity based on Input
var horizontalVelocity = ComputeHVelocity(delta, AccelerationGroundSlide, DecelerationGroundSlide); var horizontalVelocity = ComputeHVelocity(delta, AccelerationGroundSlide, DecelerationGroundSlide);
Velocity = new Vector3(horizontalVelocity.X, Velocity.Y, horizontalVelocity.Z); var newVelocityDirection = new Vector3(horizontalVelocity.X, Velocity.Y, horizontalVelocity.Z).Normalized();
var newVelocityHDirection = new Vector3(horizontalVelocity.X, 0, horizontalVelocity.Z).Normalized();
// var redirectedVelocity = newVelocityDirection.Slide(normal);
var redirectedVelocity = newVelocityDirection;
if (slopeAngleRadians > Mathf.Epsilon)
{
var slopeHDirection = new Vector3(slopeDirection.X, 0, slopeDirection.Z);
redirectedVelocity = newVelocityDirection.Lerp(slopeHDirection, delta * GroundSlideSlopeMagnetism);
var angleBetweenVelocityAndSlope = newVelocityHDirection.AngleTo(slopeHDirection);
var velocitySlopeAlignment = Mathf.Cos(angleBetweenVelocityAndSlope);
var slopeSpeedFactor = Mathf.Remap(velocitySlopeAlignment, -1, 1, 0.98, 1.02);
var speedFactorFromDownSlope = Velocity.Length() > GroundSlideDownSlopeMaxSpeed ? 1f : slopeSpeedFactor;
finalSpeed *= (float) speedFactorFromDownSlope;
// var redirectedVVelocity = slopeDirection.Y * velocitySlopeAlignment;
// redirectedVelocity = new Vector3(redirectedVelocity.X, redirectedVVelocity, redirectedVelocity.Z);
// Moving upslope and not enough speed
if (velocitySlopeAlignment < 0 && DirectGroundDetector.IsColliding() && Velocity.Length() < WalkSpeed / 2f) _playerState.SendEvent("slide_canceled");
}
else if (DirectGroundDetector.IsColliding() && Velocity.Length() < WalkSpeed / 2f)
{
// Moving on flat ground and not enough speed
_playerState.SendEvent("slide_canceled");
}
// Preserve velocity when changing direction
var finalVelocity = redirectedVelocity.Normalized() * finalSpeed;
Velocity = finalVelocity;
if (DirectGroundDetector.IsColliding())
{
GlobalPosition = new Vector3(GlobalPosition.X, position.Y, GlobalPosition.Z);
}
}
public void OnSlideCanceled()
{
_targetSpeed = WalkSpeed;
}
public void HandleSlideCanceled(float delta)
{
HandleGrounded(delta);
} }
public void HandleGroundSlide(float delta) public void HandleGroundSlide(float delta)
{ {
SlideOnGround(delta); SlideOnGround(delta);
if (MantleSystem.IsMantlePossible && IsPlayerInputtingForward()) _playerState.SendEvent("mantle"); if (MantleSystem.IsMantlePossible && IsPlayerInputtingForward()) _playerState.SendEvent("mantle");
if (!isOnFloorCustom() && !DirectGroundDetector.IsColliding())
if (!isOnFloorCustom())
_playerState.SendEvent("start_falling"); _playerState.SendEvent("start_falling");
} }
public void GlideInAir(float delta) public void GlideInAir(float delta)
{ {
var horizontalVelocity = ComputeHVelocity(delta, AccelerationAirGlide, DecelerationAirGlide); if (AllowForVelocityRedirection)
{
float verticalSpeed; // Preserve overall velocity
if (Velocity.Y < -AirGlideVSpeed) verticalSpeed = -AirGlideVSpeed; // Allows for tragic reorientation of the velocity vector after a fall
else if (Velocity.Y > 0) verticalSpeed = ComputeVerticalSpeedGravity(delta); // Allows for bunny-hoping-like movement
else verticalSpeed = Mathf.Lerp(Velocity.Y, -AirGlideVSpeed, delta); var currentVelocity = Velocity.Length();
var horizontalVelocity = ComputeHVelocity(delta, AccelerationAirGlide, DecelerationAirGlide);
Velocity = new Vector3(horizontalVelocity.X, verticalSpeed, horizontalVelocity.Z); var verticalSpeed = Velocity.Y > 0 ? ComputeVerticalSpeedGravity(delta) : Mathf.Lerp(Velocity.Y, -AirGlideVSpeed, delta*AirGlideVerticalAcceleration);
var newVelocity = new Vector3(horizontalVelocity.X, verticalSpeed, horizontalVelocity.Z);
Velocity = newVelocity.Normalized() * currentVelocity;
}
else
{
// Preserve horizontal velocity only
// Allows for mor stable descent when gliding because you don't zoom away after a long fall
// Removes bunny-hoping-like movement by simply holding slide and jump jump jump
var currentHVelocity = new Vector2(Velocity.X, Velocity.Z).Length();
var horizontalVelocity = ComputeHVelocity(delta, AccelerationAirGlide, DecelerationAirGlide);
var newHVelocity = horizontalVelocity.Normalized() * currentHVelocity;
var verticalSpeed = Velocity.Y > 0 ? ComputeVerticalSpeedGravity(delta) : Mathf.Lerp(Velocity.Y, -AirGlideVSpeed, delta*AirGlideVerticalAcceleration);
var newVelocity = new Vector3(newHVelocity.X, verticalSpeed, newHVelocity.Z);
Velocity = newVelocity;
}
} }
public void HandleAirGlide(float delta) public void HandleAirGlide(float delta)
{ {
@@ -1192,13 +1395,36 @@ public partial class PlayerController : CharacterBody3D
{ {
_targetSpeed = WalkSpeed; _targetSpeed = WalkSpeed;
} }
public void JumpFromGroundSlide()
{
_jumpStrengthMultiplier = GroundSlideJumpMultiplier + Velocity.Length()*GroundSlideJumpSpeedFactor;
}
public void JumpFromAirGlide()
{
_jumpStrengthMultiplier = AirGlideJumpMultiplier + Velocity.Length()*AirGlideJumpSpeedFactor;
}
/////////////////////////// ///////////////////////////
// Slam Management /////// // Slam Management ///////
/////////////////////////// ///////////////////////////
public void OnInputSlamPressed() public void OnInputSlamPressed()
{ {
GD.Print("Slam pressed"); _playerState.SendEvent("slam");
}
public void SlamStarted()
{
SetHorizontalVelocity(Vector2.Zero);
SetVerticalVelocity(-SlamSpeed);
}
public void HandleSlam(float delta)
{
if (isOnFloorCustom()) _playerState.SendEvent("grounded");
}
public void SlamEnded()
{
} }
/////////////////////////// ///////////////////////////
@@ -1438,7 +1664,7 @@ public partial class PlayerController : CharacterBody3D
LookAround(delta); LookAround(delta);
CameraModifications((float) delta); CameraModifications((float) delta);
HandleStairs((float) delta); MoveSlideAndHandleStairs((float) delta);
MantleSystem.ProcessMantle(_grounded.Active); MantleSystem.ProcessMantle(_grounded.Active);
if (WeaponSystem.InHandState.Active) if (WeaponSystem.InHandState.Active)
RotateWeaponWithPlayer(); RotateWeaponWithPlayer();
@@ -1456,6 +1682,4 @@ public partial class PlayerController : CharacterBody3D
DashIndicatorNode.LookAt(WeaponSystem.GlobalPosition); DashIndicatorNode.LookAt(WeaponSystem.GlobalPosition);
} }
} }
} }

View File

@@ -1,4 +1,4 @@
[gd_resource type="Resource" script_class="GUIDEMappingContext" load_steps=160 format=3 uid="uid://bl5crtu1gkrtr"] [gd_resource type="Resource" script_class="GUIDEMappingContext" load_steps=161 format=3 uid="uid://bl5crtu1gkrtr"]
[ext_resource type="Script" uid="uid://cpplm41b5bt6m" path="res://addons/guide/guide_action_mapping.gd" id="1_qmhk6"] [ext_resource type="Script" uid="uid://cpplm41b5bt6m" path="res://addons/guide/guide_action_mapping.gd" id="1_qmhk6"]
[ext_resource type="Resource" uid="uid://htqvokm8mufq" path="res://systems/inputs/base_mode/move.tres" id="2_g6bbx"] [ext_resource type="Resource" uid="uid://htqvokm8mufq" path="res://systems/inputs/base_mode/move.tres" id="2_g6bbx"]
@@ -430,21 +430,25 @@ metadata/_guide_input_mappings_collapsed = false
script = ExtResource("19_qkgmj") script = ExtResource("19_qkgmj")
button = 2 button = 2
[sub_resource type="Resource" id="Resource_kxb2c"] [sub_resource type="Resource" id="Resource_06f1o"]
script = ExtResource("15_fykw6") script = ExtResource("15_g6bbx")
[sub_resource type="Resource" id="Resource_v2ywt"] [sub_resource type="Resource" id="Resource_v2ywt"]
script = ExtResource("3_yp12v") script = ExtResource("3_yp12v")
input = SubResource("Resource_o5yys") input = SubResource("Resource_o5yys")
triggers = Array[ExtResource("8_2tfaw")]([SubResource("Resource_kxb2c")]) triggers = Array[ExtResource("8_2tfaw")]([SubResource("Resource_06f1o")])
[sub_resource type="Resource" id="Resource_qpgnj"] [sub_resource type="Resource" id="Resource_qpgnj"]
script = ExtResource("30_cvxqo") script = ExtResource("30_cvxqo")
key = 69 key = 69
[sub_resource type="Resource" id="Resource_g5tel"]
script = ExtResource("15_g6bbx")
[sub_resource type="Resource" id="Resource_s6d3g"] [sub_resource type="Resource" id="Resource_s6d3g"]
script = ExtResource("3_yp12v") script = ExtResource("3_yp12v")
input = SubResource("Resource_qpgnj") input = SubResource("Resource_qpgnj")
triggers = Array[ExtResource("8_2tfaw")]([SubResource("Resource_g5tel")])
[sub_resource type="Resource" id="Resource_vtk18"] [sub_resource type="Resource" id="Resource_vtk18"]
script = ExtResource("1_qmhk6") script = ExtResource("1_qmhk6")

View File

@@ -40,7 +40,7 @@ public partial class WallHugSystem : Node3D
{ {
foreach (RayCast3D raycast in _raycasts) foreach (RayCast3D raycast in _raycasts)
{ {
if (raycast.IsColliding()) if (raycast.IsColliding() && Math.Abs(raycast.GetCollisionNormal().Y) < 0.3f)
{ {
WallHugLocation = raycast.GetCollisionPoint().Some(); WallHugLocation = raycast.GetCollisionPoint().Some();
WallHugNormal = raycast.GetCollisionNormal().Some(); WallHugNormal = raycast.GetCollisionNormal().Some();