From 73d6da9f4627b351e5d74838d09ba07a002a904b Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 26 May 2017 11:43:05 -0700 Subject: [PATCH] Fix gracefulControls drifting rotation up --- script-archive/gracefulControls.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/script-archive/gracefulControls.js b/script-archive/gracefulControls.js index 3179044c2c..562c80e574 100644 --- a/script-archive/gracefulControls.js +++ b/script-archive/gracefulControls.js @@ -111,8 +111,11 @@ function update(dt) { var x = Reticle.getPosition().x; var y = Reticle.getPosition().y; - yawFromMouse += ((x - lastX) * movementParameters.MOUSE_YAW_SCALE * movementParameters.MOUSE_SENSITIVITY); - pitchFromMouse += ((y - lastY) * movementParameters.MOUSE_PITCH_SCALE * movementParameters.MOUSE_SENSITIVITY); + var dx = x - lastX; + var dy = y - lastY; + + yawFromMouse += (dx * movementParameters.MOUSE_YAW_SCALE * movementParameters.MOUSE_SENSITIVITY); + pitchFromMouse += (dy * movementParameters.MOUSE_PITCH_SCALE * movementParameters.MOUSE_SENSITIVITY); pitchFromMouse = Math.max(-180, Math.min(180, pitchFromMouse)); resetCursorPosition(); @@ -170,8 +173,8 @@ function scriptEnding() { } function resetCursorPosition() { - var newX = Window.x + Window.innerWidth / 2; - var newY = Window.y + Window.innerHeight / 2; + var newX = Math.floor(Window.x + Window.innerWidth / 2); + var newY = Math.floor(Window.y + Window.innerHeight / 2); Reticle.setPosition({ x: newX, y: newY}); lastX = newX; lastY = newY;