Compare commits

...

1 Commits

Author SHA1 Message Date
fffd8c947b implementing jump input buffering on grounded
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 18s
Create tag and build when new code gets to main / Export (push) Successful in 9m47s
2026-01-07 09:58:18 +01:00
2 changed files with 21 additions and 2 deletions

View File

@@ -69,6 +69,7 @@ Weight = 4.0
MantleTime = 0.3
MantlePath = ExtResource("2_6lejt")
CoyoteTime = 0.3
InputBufferFrames = 5
SimpleJumpStartVelocity = 6.0
SimpleJumpHangTimeInFrames = 1
SimpleJumpGravityLesseningFactor = 2.0

View File

@@ -89,6 +89,8 @@ public partial class PlayerController : CharacterBody3D
[ExportGroup("Jump")]
[Export(PropertyHint.Range, "0,1,0.01")]
public float CoyoteTime { get; set; } = 0.2f;
[Export(PropertyHint.Range, "0,10,1,or_greater")]
public int InputBufferFrames { get; set; } = 3;
// Simple jump
[ExportSubgroup("Simple jump")]
@@ -229,6 +231,8 @@ public partial class PlayerController : CharacterBody3D
private Transition _onLeaveWallFromRunCoyote;
private Transition _onLeaveWallFromRun;
private int _currentJumpBufferFrames = 0;
private float _playerHeight;
private float _playerRadius;
private bool _isJumpInputPressed;
@@ -466,6 +470,12 @@ public partial class PlayerController : CharacterBody3D
if (_simpleDashCooldownTimer.IsStopped())
_simpleDashCooldownTimer.Start();
if (_currentJumpBufferFrames > 0)
{
_currentJumpBufferFrames = 0;
PerformJump();
}
}
public void DashCooldownTimeout()
@@ -639,7 +649,13 @@ public partial class PlayerController : CharacterBody3D
// Jump
public void OnInputJumpStarted()
{
_currentJumpBufferFrames = InputBufferFrames;
_isJumpInputPressed = true;
PerformJump();
}
public void PerformJump()
{
if (MantleSystem.IsMantlePossible)
{
_playerState.SendEvent("mantle");
@@ -870,8 +886,8 @@ public partial class PlayerController : CharacterBody3D
SetVerticalVelocity(Velocity.Y - 2.0f);
}
// Move back to Airborne state management when starting to go down again
if (_framesSinceJumpAtApex > hangFrames)
// Move back to Airborne state when starting to go down again or if input isn't held anymore (buffered jump)
if (_framesSinceJumpAtApex > hangFrames || !_isJumpInputPressed)
_playerState.SendEvent("jump_ended");
}
public void HandleSimpleJump(float delta)
@@ -1395,6 +1411,8 @@ public partial class PlayerController : CharacterBody3D
///////////////////////////
public override void _PhysicsProcess(double delta)
{
if (_currentJumpBufferFrames > 0) _currentJumpBufferFrames -= 1;
LookAround(delta);
CameraModifications((float) delta);
HandleStairs((float) delta);