Combining three if statements into one!

This commit is contained in:
Cain Kilgore 2017-07-03 19:58:26 +01:00
parent bfcddcf3b7
commit 1c5923914b

View file

@ -15,23 +15,15 @@
var isRocketing = false; var isRocketing = false;
function checkRocketing() { function checkRocketing() {
if (HMD.active) { if (HMD.active && (Controller.Hardware.Vive || Controller.Hardware.OculusTouch) && canRocket()) {
if (Controller.Hardware.Vive || Controller.Hardware.OculusTouch) { isRocketing = true;
if (canRocket()) { MyAvatar.motorReferenceFrame = "world";
isRocketing = true; var moveVector = Vec3.multiply(Quat.getFront(Camera.getOrientation()), 10);
MyAvatar.motorReferenceFrame = "world"; if (!MyAvatar.isFlying()) {
var moveVector = Vec3.multiply(Quat.getFront(Camera.getOrientation()), 10); moveVector = Vec3.sum(moveVector, {x: 0, y: 1, z: 0});
if (!MyAvatar.isFlying()) {
moveVector = Vec3.sum(moveVector, {x: 0, y: 1, z: 0});
}
MyAvatar.motorVelocity = moveVector;
MyAvatar.motorTimescale = 1.0;
} else {
checkCanStopRocketing();
}
} else {
checkCanStopRocketing();
} }
MyAvatar.motorVelocity = moveVector;
MyAvatar.motorTimescale = 1.0;
} else { } else {
checkCanStopRocketing(); checkCanStopRocketing();
} }