From 872ec223ea6c03dc46c7bcd409b9089a871adbac Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sun, 12 Apr 2026 02:30:46 +0200 Subject: [PATCH] Adjust AUTOSTEP_PLANAR_PROGRESS_EPSILON and add closeSupportProbeDistance calculation in RapierCollisionWorld --- src/runtime-three/rapier-collision-world.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/runtime-three/rapier-collision-world.ts b/src/runtime-three/rapier-collision-world.ts index ab8fafcf..6d87fe76 100644 --- a/src/runtime-three/rapier-collision-world.ts +++ b/src/runtime-three/rapier-collision-world.ts @@ -22,7 +22,7 @@ const CHARACTER_CONTROLLER_OFFSET = 0.01; const CHARACTER_CONTROLLER_SNAP_TO_GROUND_DISTANCE = 0.2; const AUTOSTEP_MIN_WIDTH_FACTOR = 0.4285714286; const AUTOSTEP_SURFACE_PROBE_DISTANCE = 0.08; -const AUTOSTEP_PLANAR_PROGRESS_EPSILON = 0.02; +const AUTOSTEP_PLANAR_PROGRESS_EPSILON = 0.005; const COLLISION_EPSILON = 1e-5; const CAMERA_COLLISION_EPSILON = 1e-3; const MAX_WALKABLE_SLOPE_RADIANS = Math.PI * 0.25; @@ -562,10 +562,17 @@ export class RapierCollisionWorld { (resolved.collidedAxes.x || resolved.collidedAxes.z) ) { const withoutAutostep = computeResolvedMovement(motion, false); + const closeSupportProbeDistance = Math.min( + this.snapToGroundDistance, + Math.max( + AUTOSTEP_SURFACE_PROBE_DISTANCE, + (this.autostepHeight ?? AUTOSTEP_SURFACE_PROBE_DISTANCE) * 0.5 + ) + ); const landedOnStepSurface = this.probePlayerGround( resolved.nextFeetPosition, shape, - AUTOSTEP_SURFACE_PROBE_DISTANCE + closeSupportProbeDistance ).grounded; const improvedPlanarDistance = computePlanarDistance(resolved.correctedMovement) >