feat: broken crouching
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 7s
Create tag and build when new code gets to main / Export (push) Successful in 3m47s

This commit is contained in:
2025-07-06 11:49:59 +02:00
parent 85eab200ea
commit ef16d6c83f
3 changed files with 37 additions and 6 deletions

View File

@ -320,29 +320,29 @@ delay_in_seconds = "0.0"
[node name="OnCrouch" type="Node" parent="StateChart/Root/Movement/Grounded/Standing"]
script = ExtResource("28_n7qhm")
to = NodePath("../../Crouch")
to = NodePath("../../Crouched")
event = &"crouch"
delay_in_seconds = "0.0"
[node name="Crouch" type="Node" parent="StateChart/Root/Movement/Grounded"]
[node name="Crouched" type="Node" parent="StateChart/Root/Movement/Grounded"]
script = ExtResource("27_34snm")
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/Grounded/Crouch"]
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/Grounded/Crouched"]
script = ExtResource("28_n7qhm")
to = NodePath("../../../Airborne/Jump")
event = &"jump"
delay_in_seconds = "0.0"
[node name="OnAirborne" type="Node" parent="StateChart/Root/Movement/Grounded/Crouch"]
[node name="OnAirborne" type="Node" parent="StateChart/Root/Movement/Grounded/Crouched"]
script = ExtResource("28_n7qhm")
to = NodePath("../../../Airborne/CoyoteEnabled")
event = &"start_falling"
delay_in_seconds = "0.0"
[node name="OnStandUp" type="Node" parent="StateChart/Root/Movement/Grounded/Crouch"]
[node name="OnStandUp" type="Node" parent="StateChart/Root/Movement/Grounded/Crouched"]
script = ExtResource("28_n7qhm")
to = NodePath("../../Standing")
event = &"stand_up"
event = &"crouch"
delay_in_seconds = "0.0"
[node name="Mantling" type="Node" parent="StateChart/Root/Movement"]

View File

@ -66,6 +66,8 @@ public partial class PlayerController : CharacterBody3D
private StateChartState _actionHanging;
// Movement state
private StateChartState _grounded;
private StateChartState _crouched;
private StateChartState _standing;
private StateChartState _mantling;
private StateChartState _movHanging;
private StateChartState _wallHugging;
@ -132,6 +134,8 @@ public partial class PlayerController : CharacterBody3D
_actionHanging = StateChartState.Of(GetNode("StateChart/Root/Actions/Hanging"));
// Movement states
_grounded = StateChartState.Of(GetNode("StateChart/Root/Movement/Grounded"));
_standing = StateChartState.Of(GetNode("StateChart/Root/Movement/Grounded/Standing"));
_crouched = StateChartState.Of(GetNode("StateChart/Root/Movement/Grounded/Crouched"));
_mantling = StateChartState.Of(GetNode("StateChart/Root/Movement/Mantling"));
_movHanging = StateChartState.Of(GetNode("StateChart/Root/Movement/Hanging"));
_airborne = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne"));
@ -200,6 +204,8 @@ public partial class PlayerController : CharacterBody3D
_aiming.StateEntered += OnAimingEntered;
_aiming.StateExited += ResetTimeScale;
_crouched.StatePhysicsProcessing += HandleGroundedCrouched;
_standing.StatePhysicsProcessing += HandleGroundedStanding;
_grounded.StateEntered += OnGrounded;
_grounded.StatePhysicsProcessing += HandleGrounded;
_airborne.StatePhysicsProcessing += HandleAirborne;
@ -280,6 +286,16 @@ public partial class PlayerController : CharacterBody3D
_isWallJumpAvailable = true;
}
public void OnStanding()
{
}
public void OnCrouched()
{
}
public bool CanPerformDashAction()
{
return DashActionsLeft > 0 && _dashCooldownTimer.IsStopped();
@ -495,6 +511,16 @@ public partial class PlayerController : CharacterBody3D
if (!isOnFloorCustom())
_playerState.SendEvent("start_falling");
}
public void HandleGroundedStanding(float delta)
{
CapsuleCollider.UndoCrouching(delta, 1);
HeadSystem.SetHeight(CapsuleCollider.GetCurrentHeight());
}
public void HandleGroundedCrouched(float delta)
{
CapsuleCollider.Crouch(delta, 1);
HeadSystem.SetHeight(CapsuleCollider.GetCurrentHeight());
}
public void HandleAirborne(float delta)
{
if (isOnFloorCustom())