mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-17 17:43:52 +00:00
Fix: make grace “hold” instead of “pull down” don't yank us down in jumps
This commit is contained in:
parent
6880ca9ce6
commit
02dd796e2e
1 changed files with 18 additions and 9 deletions
|
|
@ -544,18 +544,27 @@ void CameraController::update(float deltaTime) {
|
||||||
grounded = false;
|
grounded = false;
|
||||||
lastGroundZ = *groundH;
|
lastGroundZ = *groundH;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
hasRealGround_ = false;
|
|
||||||
noGroundTimer_ += deltaTime;
|
|
||||||
if (noGroundTimer_ < NO_GROUND_GRACE) {
|
|
||||||
targetPos.z = lastGroundZ;
|
|
||||||
verticalVelocity = 0.0f;
|
|
||||||
grounded = true;
|
|
||||||
} else {
|
} else {
|
||||||
grounded = false;
|
hasRealGround_ = false;
|
||||||
|
noGroundTimer_ += deltaTime;
|
||||||
|
|
||||||
|
if (noGroundTimer_ < NO_GROUND_GRACE) {
|
||||||
|
// Grace should prevent instant falling at seams,
|
||||||
|
// but should NEVER pull you down or cancel a jump.
|
||||||
|
targetPos.z = std::max(targetPos.z, lastGroundZ);
|
||||||
|
|
||||||
|
// Only zero velocity if we're not moving upward.
|
||||||
|
if (verticalVelocity <= 0.0f) {
|
||||||
|
verticalVelocity = 0.0f;
|
||||||
|
grounded = true;
|
||||||
|
} else {
|
||||||
|
grounded = false; // jumping upward: don't "stick" to ghost ground
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
grounded = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Update follow target position
|
// Update follow target position
|
||||||
*followTarget = targetPos;
|
*followTarget = targetPos;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue