mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40:14 +00:00
Fix jump collision with slope grace period
Add grounded state grace to prevent fall stumbles when descending slopes while maintaining proper jump physics.
This commit is contained in:
parent
16485e691c
commit
83b364a417
1 changed files with 18 additions and 5 deletions
|
|
@ -607,9 +607,15 @@ void CameraController::update(float deltaTime) {
|
|||
float fallCatch = 3.0f;
|
||||
float dz = *groundH - feetZ;
|
||||
|
||||
// WoW-style: snap to floor if within step-up or fall-catch range,
|
||||
// but only when not moving upward (jumping)
|
||||
if (dz <= stepUp && dz >= -fallCatch && verticalVelocity <= 0.0f) {
|
||||
// Only snap when:
|
||||
// 1. Near ground (within step-up range above) - handles walking
|
||||
// 2. Actually falling from height (was airborne + falling fast)
|
||||
// 3. Was grounded + ground is close (grace for slopes)
|
||||
bool nearGround = (dz >= 0.0f && dz <= stepUp);
|
||||
bool airFalling = (!grounded && verticalVelocity < -5.0f);
|
||||
bool slopeGrace = (grounded && dz >= -1.0f && dz <= stepUp * 2.0f);
|
||||
|
||||
if (dz >= -fallCatch && (nearGround || airFalling || slopeGrace)) {
|
||||
targetPos.z = *groundH;
|
||||
verticalVelocity = 0.0f;
|
||||
grounded = true;
|
||||
|
|
@ -964,8 +970,15 @@ void CameraController::update(float deltaTime) {
|
|||
float fallCatch = 3.0f;
|
||||
float dz = *groundH - feetZ;
|
||||
|
||||
// Only snap to ground when falling/landing (not when jumping up)
|
||||
if (dz <= stepUp && dz >= -fallCatch && verticalVelocity <= 0.0f) {
|
||||
// Only snap when:
|
||||
// 1. Near ground (within step-up range above) - handles walking
|
||||
// 2. Actually falling from height (was airborne + falling fast)
|
||||
// 3. Was grounded + ground is close (grace for slopes)
|
||||
bool nearGround = (dz >= 0.0f && dz <= stepUp);
|
||||
bool airFalling = (!grounded && verticalVelocity < -5.0f);
|
||||
bool slopeGrace = (grounded && dz >= -1.0f && dz <= stepUp * 2.0f);
|
||||
|
||||
if (dz >= -fallCatch && (nearGround || airFalling || slopeGrace)) {
|
||||
newPos.z = *groundH + eyeHeight;
|
||||
verticalVelocity = 0.0f;
|
||||
grounded = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue