fix(physics): jump apex velocity zeroing bug
SmallVelocity threshold (0.25 m/s) in UpdatePhysicsInternal was zeroing velocity every frame while airborne at the jump apex. With vel~0.01 m/s and gravity adding only 0.012/frame, the zeroing won every frame and the character got stuck at peak height forever. Fix: only apply small-velocity zeroing when OnWalkable (grounded). While airborne, gravity must accumulate freely through the zero-crossing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
157ed9d974
commit
31cd5480dc
3 changed files with 32 additions and 8 deletions
|
|
@ -298,7 +298,10 @@ public sealed class PhysicsBody
|
|||
calc_friction(dt, velocityMag2);
|
||||
|
||||
// If velocity fell below the "small" threshold after friction, stop.
|
||||
if (velocityMag2 - SmallVelocitySquared < 0.0002f)
|
||||
// Only apply when grounded — while airborne, gravity must accumulate
|
||||
// even when velocity is near zero (e.g., at jump apex).
|
||||
if (velocityMag2 - SmallVelocitySquared < 0.0002f
|
||||
&& TransientState.HasFlag(TransientStateFlags.OnWalkable))
|
||||
Velocity = Vector3.Zero;
|
||||
|
||||
// Euler integration: position += v*dt + 0.5*a*dt²
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue