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"] [node name="OnCrouch" type="Node" parent="StateChart/Root/Movement/Grounded/Standing"]
script = ExtResource("28_n7qhm") script = ExtResource("28_n7qhm")
to = NodePath("../../Crouch") to = NodePath("../../Crouched")
event = &"crouch" event = &"crouch"
delay_in_seconds = "0.0" 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") 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") script = ExtResource("28_n7qhm")
to = NodePath("../../../Airborne/Jump") to = NodePath("../../../Airborne/Jump")
event = &"jump" event = &"jump"
delay_in_seconds = "0.0" 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") script = ExtResource("28_n7qhm")
to = NodePath("../../../Airborne/CoyoteEnabled") to = NodePath("../../../Airborne/CoyoteEnabled")
event = &"start_falling" event = &"start_falling"
delay_in_seconds = "0.0" 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") script = ExtResource("28_n7qhm")
to = NodePath("../../Standing") to = NodePath("../../Standing")
event = &"stand_up" event = &"crouch"
delay_in_seconds = "0.0" delay_in_seconds = "0.0"
[node name="Mantling" type="Node" parent="StateChart/Root/Movement"] [node name="Mantling" type="Node" parent="StateChart/Root/Movement"]

View File

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

View File

@ -34,4 +34,9 @@ public partial class HeadSystem : Node3D
{ {
return GetGlobalTransform().Basis.Z; return GetGlobalTransform().Basis.Z;
} }
public void SetHeight(float height)
{
Position = new Vector3(Position.X, height, Position.Z);
}
} }