Add test for airborne input pushing into a wall

This commit is contained in:
2026-04-12 01:47:19 +02:00
parent c575d6d042
commit 546f203012

View File

@@ -382,6 +382,76 @@ describe("player-locomotion", () => {
expect(step?.verticalVelocity).toBeLessThan(0);
});
it("keeps falling when airborne input pushes into a wall and the pre-move probe flickers grounded", () => {
let probeCount = 0;
const step = stepPlayerLocomotion({
dt: 0.1,
feetPosition: {
x: 0,
y: 1,
z: 0
},
movementYawRadians: 0,
standingShape: FIRST_PERSON_PLAYER_SHAPE,
verticalVelocity: -1.5,
previousLocomotionState: createIdleRuntimeLocomotionState("airborne"),
previousPlanarDisplacement: {
x: 0,
y: 0,
z: 0.45
},
jumpBufferRemainingMs: 0,
coyoteTimeRemainingMs: 0,
jumpHoldRemainingMs: 0,
crouched: false,
wasJumpPressed: false,
input: FORWARD_INPUT,
movement: DEFAULT_MOVEMENT,
resolveMotion: (feetPosition, motion): ResolvedPlayerMotion => ({
feetPosition: {
x: feetPosition.x + motion.x * 0.2,
y: feetPosition.y + motion.y,
z: feetPosition.z + motion.z
},
grounded: false,
collisionCount: 1,
groundCollisionNormal: null,
collidedAxes: {
x: true,
y: false,
z: false
}
}),
resolveVolumeState: () => createVolumeState(),
probeGround: () => {
probeCount += 1;
if (probeCount === 1) {
return {
grounded: true,
distance: 0,
normal: { x: 0, y: 1, z: 0 },
slopeDegrees: 0
};
}
return {
grounded: false,
distance: null,
normal: null,
slopeDegrees: null
};
},
canOccupyShape: () => true
});
expect(step).not.toBeNull();
expect(step?.locomotionState.grounded).toBe(false);
expect(step?.locomotionState.locomotionMode).toBe("airborne");
expect(step?.verticalVelocity).toBeLessThan(-1.5);
});
it("sinks toward the water surface while keeping the head above water", () => {
const step = stepPlayerLocomotion({
dt: 0.1,