mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 15:50:20 +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;
|
||||
lastGroundZ = *groundH;
|
||||
}
|
||||
} else {
|
||||
hasRealGround_ = false;
|
||||
noGroundTimer_ += deltaTime;
|
||||
if (noGroundTimer_ < NO_GROUND_GRACE) {
|
||||
targetPos.z = lastGroundZ;
|
||||
verticalVelocity = 0.0f;
|
||||
grounded = true;
|
||||
} 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
|
||||
*followTarget = targetPos;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue