Update RapierCollisionWorld to include grounded probe and correct feet position calculation

This commit is contained in:
2026-04-12 01:30:17 +02:00
parent 7cadda83f9
commit 42fe430944

View File

@@ -500,6 +500,7 @@ export class RapierCollisionWorld {
y: currentCenter.y + correctedMovement.y, y: currentCenter.y + correctedMovement.y,
z: currentCenter.z + correctedMovement.z z: currentCenter.z + correctedMovement.z
}; };
const nextFeetPosition = colliderCenterToFeetPosition(nextCenter, shape);
const collisionCount = this.characterController.numComputedCollisions(); const collisionCount = this.characterController.numComputedCollisions();
let groundCollisionNormal: Vec3 | null = null; let groundCollisionNormal: Vec3 | null = null;
@@ -520,12 +521,15 @@ export class RapierCollisionWorld {
this.playerCollider.setTranslation(nextCenter); this.playerCollider.setTranslation(nextCenter);
const groundedProbe = this.probePlayerGround(
nextFeetPosition,
shape,
this.snapToGroundDistance
);
return { return {
feetPosition: colliderCenterToFeetPosition(nextCenter, shape), feetPosition: nextFeetPosition,
grounded: grounded: groundedProbe.grounded,
this.characterController.computedGrounded() ||
groundCollisionNormal !== null ||
(motion.y < 0 && collidedAxes.y),
collisionCount, collisionCount,
groundCollisionNormal, groundCollisionNormal,
collidedAxes collidedAxes