- Home /
Handling mouse input with VSync off
I've noticed that the mouse info I get from Input.GetAxis("Mouse X") is very different depending on if I have VSync on or off.
This is me moving the mouse as smoothly as I can to the left...
Here's a set of data with VSync on:
[0003.353] InputManager.Update() MX:-0.05000 MY:0.00000
[0003.368] InputManager.Update() MX:-0.10000 MY:0.00000
[0003.385] InputManager.Update() MX:-0.15000 MY:0.00000
[0003.402] InputManager.Update() MX:-0.20000 MY:0.00000
[0003.418] InputManager.Update() MX:-0.20000 MY:0.00000
[0003.435] InputManager.Update() MX:-0.20000 MY:0.00000
Here's a set of data with VSync off:
[0001.173] InputManager.Update() MX:-0.10000 MY:0.00000
[0001.175] InputManager.Update() MX:0.00000 MY:0.00000
[0001.177] InputManager.Update() MX:0.00000 MY:0.00000
[0001.179] InputManager.Update() MX:0.00000 MY:0.00000
[0001.180] InputManager.Update() MX:-0.10000 MY:0.00000
[0001.182] InputManager.Update() MX:0.00000 MY:0.00000
[0001.184] InputManager.Update() MX:0.00000 MY:0.00000
The 0 values between the -0.1 values surprised me.
Using the input, I multiply the value by a rotation velocity and time.deltaTime. Everything worked perfect until I disabled Vsync.
The problem I have is that when VSync is off I get a value of 0.0 back so the velocity isn't consistent and the character rotates much more slowly (since velocity is != 0 only every 0.016 ms vs every frame).
How do others create consistent mouse behavior regardless of Vsync being on or off?
Answer by totti · Mar 23, 2014 at 12:16 PM
Don't use Time.deltaTime because Input.GetAxis is already frame-rate independent.
Your answer
Follow this Question
Related Questions
Reacting to Mouse animation... 2 Answers
swiping with mouse input 0 Answers
Mouse position to Isometric Grid Tile number 1 Answer
aiming with animation 1 Answer
make an object glow when mouse over 3 Answers