From 2f11501e5b8f3fa5ff8049e8fbd8948f51fcb3c3 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Tue, 2 Dec 2014 14:28:46 -0800 Subject: [PATCH] Fix constant movement with hydra by adding null zone for thrust --- examples/hydraMove.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/hydraMove.js b/examples/hydraMove.js index 236cecab18..f469fbbe74 100644 --- a/examples/hydraMove.js +++ b/examples/hydraMove.js @@ -245,10 +245,15 @@ function handleGrabBehavior(deltaTime) { } // Update for joysticks and move button +var THRUST_DEAD_ZONE = 0.1; function flyWithHydra(deltaTime) { var thrustJoystickPosition = Controller.getJoystickPosition(THRUST_CONTROLLER); - if (thrustJoystickPosition.x != 0 || thrustJoystickPosition.y != 0) { + if (debug) { + print("thrust X: " + thrustJoystickPosition.x + " Y: " + thrustJoystickPosition.y); + } + + if (Math.abs(thrustJoystickPosition.x) > THRUST_DEAD_ZONE || Math.abs(thrustJoystickPosition.y) > THRUST_DEAD_ZONE) { if (thrustMultiplier < MAX_THRUST_MULTIPLIER) { thrustMultiplier *= 1 + (deltaTime * THRUST_INCREASE_RATE); }