Add air direction only setting for player movement
This commit is contained in:
@@ -574,6 +574,70 @@ describe("player-locomotion", () => {
|
||||
expect(step?.locomotionState.planarSpeed).toBeCloseTo(0);
|
||||
});
|
||||
|
||||
it("reorients airborne movement using existing speed without adding more", () => {
|
||||
const step = stepPlayerLocomotion({
|
||||
dt: 0.1,
|
||||
feetPosition: {
|
||||
x: 0,
|
||||
y: 1,
|
||||
z: 0
|
||||
},
|
||||
movementYawRadians: 0,
|
||||
airDirectionYawRadians: Math.PI / 2,
|
||||
standingShape: FIRST_PERSON_PLAYER_SHAPE,
|
||||
verticalVelocity: -2,
|
||||
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,
|
||||
jump: {
|
||||
...DEFAULT_MOVEMENT.jump,
|
||||
directionOnly: true
|
||||
}
|
||||
},
|
||||
resolveMotion: (feetPosition, motion): ResolvedPlayerMotion => ({
|
||||
feetPosition: {
|
||||
x: feetPosition.x + motion.x,
|
||||
y: feetPosition.y + motion.y,
|
||||
z: feetPosition.z + motion.z
|
||||
},
|
||||
grounded: false,
|
||||
collisionCount: 0,
|
||||
groundCollisionNormal: null,
|
||||
collidedAxes: {
|
||||
x: false,
|
||||
y: false,
|
||||
z: false
|
||||
}
|
||||
}),
|
||||
resolveVolumeState: () => createVolumeState(),
|
||||
probeGround: () => ({
|
||||
grounded: false,
|
||||
distance: null,
|
||||
normal: null,
|
||||
slopeDegrees: null
|
||||
}),
|
||||
canOccupyShape: () => true
|
||||
});
|
||||
|
||||
expect(step).not.toBeNull();
|
||||
expect(step?.locomotionState.locomotionMode).toBe("airborne");
|
||||
expect(step?.planarDisplacement.x).toBeCloseTo(0.45);
|
||||
expect(step?.planarDisplacement.z).toBeCloseTo(0);
|
||||
expect(step?.locomotionState.requestedPlanarSpeed).toBeCloseTo(4.5);
|
||||
expect(step?.locomotionState.planarSpeed).toBeCloseTo(4.5);
|
||||
});
|
||||
|
||||
it("sinks toward the water surface while keeping the head above water", () => {
|
||||
const step = stepPlayerLocomotion({
|
||||
dt: 0.1,
|
||||
|
||||
Reference in New Issue
Block a user