gd: made wall jump more intuitive and act like a double jump
Some checks failed
Create tag and build when new code gets to main / BumpTag (push) Successful in 17s
Create tag and build when new code gets to main / Export (push) Failing after 1s

This commit is contained in:
2025-07-04 14:15:09 +02:00
parent cf98e6c36c
commit 767d0fc768
6 changed files with 50 additions and 20 deletions

View File

@ -55,6 +55,8 @@ public partial class PlayerController : CharacterBody3D
public int DashActionsLeft { get; set; }
private bool _isWallJumpAvailable = true;
private StateChart _playerState;
// Actions state
private StateChartState _weaponInHand;
@ -275,6 +277,7 @@ public partial class PlayerController : CharacterBody3D
public void OnGrounded()
{
DashActionsLeft = MaxNumberOfDashActions;
_isWallJumpAvailable = true;
}
public bool CanPerformDashAction()
@ -284,6 +287,7 @@ public partial class PlayerController : CharacterBody3D
public void PerformDashAction()
{
_isWallJumpAvailable = true;
_dashCooldownTimer.Start();
DashActionsLeft--;
}
@ -303,24 +307,30 @@ public partial class PlayerController : CharacterBody3D
{
_playerState.SendEvent("jump_from_dash");
PerformDashAction();
PerformJump(MoveSystem.JumpTypes.JUMP_FROM_DASH);
PerformJump(MoveSystem.JumpTypes.JumpFromDash);
return;
}
_playerState.SendEvent("to_double_jump");
PerformJump(MoveSystem.JumpTypes.SIMPLE_JUMP);
PerformJump(MoveSystem.JumpTypes.SimpleJump);
}
public void JumpFromWall()
{
if (!_isWallJumpAvailable)
return;
_isWallJumpAvailable = false;
var wallNormal = WallHugSystem.GetWallNormal().UnwrapOr(Vector3.Up);
var isLookingTowardsWall = HeadSystem.GetForwardHorizontalVector().Dot(wallNormal) > 0.7;
var jumpDirection = isLookingTowardsWall ? Vector3.Up : wallNormal;
if (_aiming.Active && CanPerformDashAction())
{
_playerState.SendEvent("jump_from_dash");
PerformDashAction();
PerformJump(MoveSystem.JumpTypes.JUMP_FROM_DASH, wallNormal);
PerformJump(MoveSystem.JumpTypes.JumpFromDash, jumpDirection);
return;
}
_playerState.SendEvent("to_double_jump");
PerformJump(MoveSystem.JumpTypes.SIMPLE_JUMP, wallNormal);
_playerState.SendEvent("jump_from_wall");
PerformJump(MoveSystem.JumpTypes.JumpFromWall, jumpDirection);
}
public void DoubleJump()
{
@ -328,10 +338,10 @@ public partial class PlayerController : CharacterBody3D
if (_aiming.Active && CanPerformDashAction())
{
PerformDashAction();
PerformJump(MoveSystem.JumpTypes.JUMP_FROM_DASH);
PerformJump(MoveSystem.JumpTypes.JumpFromDash);
return;
}
PerformJump(MoveSystem.JumpTypes.DOUBLE_JUMP);
PerformJump(MoveSystem.JumpTypes.DoubleJump);
}
private void PerformJump(MoveSystem.JumpTypes jumpType, Vector3? jumpDirection = null)
{
@ -341,8 +351,8 @@ public partial class PlayerController : CharacterBody3D
var proportionOfTimeGone = _timeAfterDashingTimer.TimeLeft / _timeAfterDashingTimer.WaitTime;
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
if (makeItDouble && jumpType == MoveSystem.JumpTypes.SimpleJump)
jumpType = MoveSystem.JumpTypes.DoubleJump; // convert simple jump to double if done right after a dash
_timeAfterDashingTimer.Stop();
bool doesCapsuleHaveCrouchingHeight = CapsuleCollider.IsCrouchingHeight();