Fix flying bug.

This commit is contained in:
r3tk0n 2019-03-21 16:53:53 -07:00
parent 108e8b9994
commit 4301d74df5

View file

@ -3434,7 +3434,7 @@ glm::vec3 MyAvatar::calculateScaledDirection(){
if (state == CharacterController::State::Hover || if (state == CharacterController::State::Hover ||
_characterController.computeCollisionMask() == BULLET_COLLISION_MASK_COLLISIONLESS) { _characterController.computeCollisionMask() == BULLET_COLLISION_MASK_COLLISIONLESS) {
glm::vec3 up = (getDriveKey(TRANSLATE_Y)) * IDENTITY_UP; glm::vec3 up = (getDriveKey(TRANSLATE_Y)) * IDENTITY_UP;
up /= glm::length(up); //up /= glm::length(up);
direction += up; direction += up;
} }
@ -3464,12 +3464,6 @@ void MyAvatar::updateActionMotor(float deltaTime) {
float directionLength = glm::length(direction); float directionLength = glm::length(direction);
_isPushing = directionLength > EPSILON; _isPushing = directionLength > EPSILON;
//if (_isPushing) {
// direction;
//} else {
// direction = Vectors::ZERO;
//}
if (!_isPushing) { if (!_isPushing) {
direction = Vectors::ZERO; direction = Vectors::ZERO;
} }
@ -3486,7 +3480,7 @@ void MyAvatar::updateActionMotor(float deltaTime) {
const float maxBoostSpeed = sensorToWorldScale * MAX_BOOST_SPEED; const float maxBoostSpeed = sensorToWorldScale * MAX_BOOST_SPEED;
if (_isPushing) { if (_isPushing) {
direction /= direction; direction /= directionLength;
if (motorSpeed < maxBoostSpeed) { if (motorSpeed < maxBoostSpeed) {
// an active action motor should never be slower than this // an active action motor should never be slower than this
float boostCoefficient = (maxBoostSpeed - motorSpeed) / maxBoostSpeed; float boostCoefficient = (maxBoostSpeed - motorSpeed) / maxBoostSpeed;