Add air movement controls for player in App.tsx and related files

This commit is contained in:
2026-04-12 02:06:00 +02:00
parent 41dd4dc434
commit 8aba9a02d7
9 changed files with 138 additions and 2 deletions

View File

@@ -63,6 +63,8 @@ function cloneRuntimePlayerMovement(
coyoteTimeMs: movement.jump.coyoteTimeMs,
variableHeight: movement.jump.variableHeight,
maxHoldMs: movement.jump.maxHoldMs,
moveWhileJumping: movement.jump.moveWhileJumping,
moveWhileFalling: movement.jump.moveWhileFalling,
bunnyHop: movement.jump.bunnyHop,
bunnyHopBoost: movement.jump.bunnyHopBoost
},

View File

@@ -239,6 +239,18 @@ function computePlanarSpeedFromDisplacement(
return Math.hypot(displacement.x, displacement.z) / dt;
}
function clearPlanarMovementInput(
input: PlayerStartActionInputState
): PlayerStartActionInputState {
return {
...input,
moveForward: 0,
moveBackward: 0,
moveLeft: 0,
moveRight: 0
};
}
function isWaterLocomotionMode(
locomotionMode: RuntimeLocomotionMode | null | undefined
): boolean {
@@ -480,6 +492,17 @@ export function stepPlayerLocomotion(
coyoteTimeRemainingMs = 0;
}
const airMovementAllowed =
currentlyGrounded ||
jumpTriggered ||
currentSwimmableWater ||
(options.verticalVelocity > VERTICAL_ASCENT_EPSILON
? options.movement.jump.moveWhileJumping
: options.movement.jump.moveWhileFalling);
const planarInput = airMovementAllowed
? options.input
: clearPlanarMovementInput(options.input);
const requestedPlanarSpeed =
activeShape.mode !== "none" && !currentSwimmableWater
? jumpTriggered
@@ -490,7 +513,7 @@ export function stepPlayerLocomotion(
: groundedRequestedPlanarSpeed;
const planarMotionFromInput = computePlanarMotion(
options.movementYawRadians,
options.input,
planarInput,
requestedPlanarSpeed,
options.dt
);

View File

@@ -285,6 +285,8 @@ function clonePlayerStartJumpSettings(
coyoteTimeMs: jump.coyoteTimeMs,
variableHeight: jump.variableHeight,
maxHoldMs: jump.maxHoldMs,
moveWhileJumping: jump.moveWhileJumping,
moveWhileFalling: jump.moveWhileFalling,
bunnyHop: jump.bunnyHop,
bunnyHopBoost: jump.bunnyHopBoost
};

View File

@@ -77,6 +77,8 @@ function cloneRuntimePlayerMovement(
coyoteTimeMs: movement.jump.coyoteTimeMs,
variableHeight: movement.jump.variableHeight,
maxHoldMs: movement.jump.maxHoldMs,
moveWhileJumping: movement.jump.moveWhileJumping,
moveWhileFalling: movement.jump.moveWhileFalling,
bunnyHop: movement.jump.bunnyHop,
bunnyHopBoost: movement.jump.bunnyHopBoost
},