mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
"hover" if the "jump" key is held down long enough
This commit is contained in:
parent
be5fdbf217
commit
bee8c0e237
2 changed files with 16 additions and 0 deletions
|
@ -232,6 +232,7 @@ CharacterController::CharacterController(AvatarData* avatarData) {
|
|||
_isOnGround = false;
|
||||
_isJumping = false;
|
||||
_isHovering = true;
|
||||
_jumpToHoverStart = 0;
|
||||
setMaxSlope(btRadians(45.0f));
|
||||
_lastStepUp = 0.0f;
|
||||
_pendingFlags = 0;
|
||||
|
@ -678,6 +679,20 @@ bool CharacterController::canJump() const {
|
|||
|
||||
void CharacterController::jump() {
|
||||
_pendingFlags |= PENDING_FLAG_JUMP;
|
||||
|
||||
// check for case where user is holding down "jump" key...
|
||||
// we'll eventually tansition to "hover"
|
||||
if (!_isHovering) {
|
||||
if (!_isJumping) {
|
||||
_jumpToHoverStart = usecTimestampNow();
|
||||
} else {
|
||||
quint64 now = usecTimestampNow();
|
||||
const quint64 JUMP_TO_HOVER_PERIOD = USECS_PER_SECOND;
|
||||
if (now - _jumpToHoverStart < JUMP_TO_HOVER_PERIOD) {
|
||||
_isHovering = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CharacterController::setGravity(btScalar gravity) {
|
||||
|
|
|
@ -85,6 +85,7 @@ protected:
|
|||
bool _isOnGround;
|
||||
bool _isJumping;
|
||||
bool _isHovering;
|
||||
quint64 _jumpToHoverStart;
|
||||
btScalar _velocityTimeInterval;
|
||||
btScalar _stepDt;
|
||||
uint32_t _pendingFlags;
|
||||
|
|
Loading…
Reference in a new issue