Mouse sensitivity changes between editor and built exe
Asked Answered
G

2

0

Script is attached to a sphere which can be moved about using the mouse. While playing in the editor the sphere moves at a reasonable speed - but after building, the mouse sensitivity (relative to moving the sphere) becomes very low (sphere moves at about 1/5th speed). I have tried different resolution/quality settings but none seem to affect the mouse sensitivity.

function Update ()
{
    var x_delta = speed * Input.GetAxis ("Mouse X") * Time.deltaTime;
    var z_delta = speed * Input.GetAxis ("Mouse Y") * Time.deltaTime;
    transform.Translate (Vector3 (x_delta, 0, z_delta));
    Screen.lockCursor = true;
}
Gaylagayle answered 10/1 at 8:15 Comment(0)
G
0

Mouse movement is already framerate-independent to begin with. Multiplying it by Time.deltaTime makes it framerate-dependent. Say it takes you one second to move the mouse from one side of a mouse mat to the other…it will always take one second to do this, regardless of the framerate of the game.

Griffiths answered 10/1 at 8:14 Comment(1)

You sir, are a prince amongst coders! Problem solved.

Gaylagayle
A
0

Input.GetAxis("Mouse X") returns difference between previous and current mouse position.
If framerate is high, differences will be tiny, but more frequent.
If framerate is low, differences will be large, but infrequent
So, in this case, there is indeed no need to compensate by Time.deltaTime any further!
That was actually a revelation to me after so many years! :smiley:

however:

Input.GetAxis("Horizontal") or Input.GetAxisRaw("Horizontal") is for keyboard, and returns value between 0 and 1, which will need to be scaled by Time.deltaTime

So for stuff like Input.GetKey(KeyCode.W) you do need *Time.deltaTime because they are discrete.
But for any kind of mouse-deltas you don’t.

Analphabetic answered 10/1 at 8:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.