Enhance navigation controllers with jump buffer, coyote time, and jump hold features

This commit is contained in:
2026-04-11 20:10:01 +02:00
parent ad01f5050f
commit 1811d85552
2 changed files with 62 additions and 0 deletions

View File

@@ -54,6 +54,19 @@ function cloneRuntimePlayerMovement(
jump: movement.capabilities.jump,
sprint: movement.capabilities.sprint,
crouch: movement.capabilities.crouch
},
jump: {
speed: movement.jump.speed,
bufferMs: movement.jump.bufferMs,
coyoteTimeMs: movement.jump.coyoteTimeMs,
variableHeight: movement.jump.variableHeight,
maxHoldMs: movement.jump.maxHoldMs
},
sprint: {
speedMultiplier: movement.sprint.speedMultiplier
},
crouch: {
speedMultiplier: movement.crouch.speedMultiplier
}
};
}
@@ -110,6 +123,9 @@ export class FirstPersonNavigationController implements NavigationController {
private previousTelemetry: PlayerControllerTelemetry | null = null;
private latestJumpStarted = false;
private latestHeadBump = false;
private jumpBufferRemainingMs = 0;
private coyoteTimeRemainingMs = 0;
private jumpHoldRemainingMs = 0;
activate(ctx: RuntimeControllerContext): void {
this.context = ctx;
@@ -205,6 +221,9 @@ export class FirstPersonNavigationController implements NavigationController {
this.jumpPressed = false;
this.latestJumpStarted = false;
this.latestHeadBump = false;
this.jumpBufferRemainingMs = 0;
this.coyoteTimeRemainingMs = 0;
this.jumpHoldRemainingMs = 0;
this.previousTelemetry = null;
ctx.setRuntimeMessage(null);
ctx.setPlayerControllerTelemetry(null);
@@ -238,6 +257,9 @@ export class FirstPersonNavigationController implements NavigationController {
this.previousTelemetry = null;
this.latestJumpStarted = false;
this.latestHeadBump = false;
this.jumpBufferRemainingMs = 0;
this.coyoteTimeRemainingMs = 0;
this.jumpHoldRemainingMs = 0;
}
update(dt: number): void {
@@ -273,6 +295,9 @@ export class FirstPersonNavigationController implements NavigationController {
standingShape: this.standingPlayerShape,
verticalVelocity: this.verticalVelocity,
previousLocomotionState: this.locomotionState,
jumpBufferRemainingMs: this.jumpBufferRemainingMs,
coyoteTimeRemainingMs: this.coyoteTimeRemainingMs,
jumpHoldRemainingMs: this.jumpHoldRemainingMs,
crouched: this.locomotionState.crouched,
wasJumpPressed: this.jumpPressed,
input: inputState,
@@ -306,6 +331,9 @@ export class FirstPersonNavigationController implements NavigationController {
this.feetPosition = locomotionStep.feetPosition;
this.activePlayerShape = locomotionStep.activeShape;
this.verticalVelocity = locomotionStep.verticalVelocity;
this.jumpBufferRemainingMs = locomotionStep.jumpBufferRemainingMs;
this.coyoteTimeRemainingMs = locomotionStep.coyoteTimeRemainingMs;
this.jumpHoldRemainingMs = locomotionStep.jumpHoldRemainingMs;
this.jumpPressed = locomotionStep.jumpPressed;
this.latestJumpStarted = locomotionStep.jumpStarted;
this.latestHeadBump = locomotionStep.headBump;
@@ -339,6 +367,9 @@ export class FirstPersonNavigationController implements NavigationController {
this.previousTelemetry = null;
this.latestJumpStarted = false;
this.latestHeadBump = false;
this.jumpBufferRemainingMs = 0;
this.coyoteTimeRemainingMs = 0;
this.jumpHoldRemainingMs = 0;
this.inWaterVolume = false;
this.inFogVolume = false;
this.updateCameraTransform();