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