Mouse Movement Problem

Hi everyone,

I have a problem, it goes like this;

At Project Settings → Input Manager, my Mouse X and Mouse Y are at their default settings.

When I use Mouse X and Mouse Y values to create a smooth movement for mouseLook script, I saw that Gravity and Dead settings in the input manager means nothing (I tried a lot of different combinations) and they don’t change the behaviour.

After seeing that those settings doesn’t help, I edited the mouseLook.cs to suit my smooth camera needs and I have a script now, which works just like intended in Unity editor. But after I build the application, smooth doesn’t work anymore.

I multiplied the values I get from mouse movement with Time.deltaTime. deltaTime had to fix the values without depending on the fps but it doesn’t.

In Unity editor, it works well with 60fps but the built version which I run in my workstation(approx 2000fps) works differently and it also works different than both on my laptop (160fps).

After that, I also tested it using FixedUpdate() and fixedDeltaTime functions and their combinations.

I also tried the smooth camera functions shared on this forum and UnifyCommunity and they have the same problems.

So I think, Input.GetAxis(“Mouse X”) and Input.GetAxis(“Mouse Y”) and even Input.GetAxisRaw(“Mouse X”) and Input.GetAxisRaw(“Mouse Y”) doesn’t get affected by deltaTime nor fixedUpdate or I couldn’t manage them to work with those.

The code below returns the value for Mouse X and it looks different in the Unity editor and Built application. How can I fix that mouse value not depending on the fps, so it works all the same without depending on the app. speed?

Thanks

private var mx; // Mouse X
private var mxR; // Mouse X Raw
private var mxDelta; // Mouse X deltaTime
private var mxRDelta; // Mouse X Raw deltaTime

function Update () 
{
	Screen.lockCursor = true;
	mx = Input.GetAxis("Mouse X");
	mxR = Input.GetAxisRaw("Mouse X");
	mxDelta = Input.GetAxis("Mouse X") * Time.deltaTime;
	mxRDelta = Input.GetAxisRaw("Mouse X") * Time.deltaTime;
}

function OnGUI()
{
	GUI.Label(Rect(10,10,400,20),"Mouse X = "+mx.ToString());
	GUI.Label(Rect(10,30,400,20),"Mouse X Raw = "+mxR.ToString());
	GUI.Label(Rect(10,50,400,20),"Mouse X Delta = "+mxDelta.ToString());
	GUI.Label(Rect(10,70,400,20),"Mouse X Raw Delta= "+mxRDelta.ToString());
}

Mouse movement is already framerate-independent to begin with…you shouldn’t be multiplying it by Time.deltaTime, because that will actually make it framerate-dependent. The gravity etc. settings are for keyboard input; wouldn’t really make sense to apply that to mouse movement as it’s a completely different thing.

–Eric

Thanks for the answer Eric,

When I do not multiply the mouse movement values with the deltaTime, mouse movement doesn’t return smooth in the editor. But when I multiply the rotateYaw and rotatePitch which are controlling the camera and character with deltaTime, I get the smooth movement because it fixes the fps at 64. But when I build this application and play it on my workstation, the application runs at around 2000fps(I don’t want to use vsync) so it doesn’t return smooth variables. In my laptop, the smooth movement in the editor runs faster (160fps).

I created a unity package about this issue, I would appreciate it if you could test and recommend a solution.

Thanx.

213896–7848–$smoothmouselook_563.unitypackage (14.9 KB)