From eb8e912808b9aea8c177c3ecaf780696a3c6bbc4 Mon Sep 17 00:00:00 2001 From: Saracen Date: Thu, 11 Apr 2019 03:29:58 +0100 Subject: [PATCH] Added missing checks to ground and takeoff state. --- libraries/physics/src/CharacterController.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libraries/physics/src/CharacterController.cpp b/libraries/physics/src/CharacterController.cpp index 9e5b7f8336..45489781e8 100755 --- a/libraries/physics/src/CharacterController.cpp +++ b/libraries/physics/src/CharacterController.cpp @@ -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");