Added missing checks to ground and takeoff state.

This commit is contained in:
Saracen 2019-04-11 03:29:58 +01:00
parent bce80130bd
commit eb8e912808

View file

@ -754,7 +754,11 @@ void CharacterController::updateState() {
switch (_state) {
case State::Ground:
if (!rayHasHit && !_hasSupport) {
SET_STATE(State::Hover, "no ground detected");
if (_useFallHeightThreshold) {
SET_STATE(State::Hover, "no ground detected");
} else {
SET_STATE(State::InAir, "falling");
}
} else if (_pendingFlags & PENDING_FLAG_JUMP && _jumpButtonDownCount != _takeoffJumpButtonID) {
_takeoffJumpButtonID = _jumpButtonDownCount;
_takeoffToInAirStartTime = now;
@ -764,7 +768,7 @@ void CharacterController::updateState() {
}
break;
case State::Takeoff:
if (!rayHasHit && !_hasSupport) {
if (_useFallHeightThreshold && (!rayHasHit && !_hasSupport)) {
SET_STATE(State::Hover, "no ground");
} else if ((now - _takeoffToInAirStartTime) > TAKE_OFF_TO_IN_AIR_PERIOD) {
SET_STATE(State::InAir, "takeoff done");