Look at this video I recorded. Its 8x times slower and I made it to show how unity deals with input .
As you can see, it takes quite a bit of time for Unity to notice I started moving my cursor… Why is it so slow? I have Vsync off,mouse script is second or first in script execution order, 60 stable fps(simple scene too).
It is really bad, bad aim accuracy for a shooter game.Any other games I play have crisp mouse response.
Why is this? Is there anything to do?
I ve seen this question actually been asked before by others, but nobody wants to deal with it .Seems like devs want to dodge the question/issue.
I dont know if there really is something on unity side causing the mouse to be slow, but can we see some code just in case it might be something on your side?
For example, I used to do Input.GetAxis(“Mouse X”) * Time.deltaTime, but later learned you are not suppose to multiply it by deltaTime since the value Mouse X returns is the distance the mouse moved since last frame, which is already framerate independent.
Multiplying it by deltaTime will now make it framerate dependent, which is bad.
Edit - My tests were flawed so all the results are wrong. See this thread for an update
I was curious, so I did a test and it seems that unity does have some delay with inputs, though I dont think this is your issue.
Its hard to tell with your video, but is your issue that your mouse feels like its being smoothed? Maybe thats just the slow motion you did that is making it look weird to me. Also, those mouse trails makes it hard to tell what is a single frame and what not.
Here was my input test…
(The video says my framerate was 170, but I think it was actually around 100 due to the recording making things slower, but that shouldnt matter anyways) Edit - Removed video due to inaccurate test
The mouse code was just this
Click for code
using UnityEngine;
public class Mouse : MonoBehaviour
{
public float speed = 10000;
void Update()
{
transform.Rotate(0, Input.GetAxis("Mouse X") * speed, 0);
}
}
It seems to be on average a 2 - 3 frames delay (never lower than 2, and actually, I might have never gotten 2, only 3). I was expecting 0 - 1 frame delay. When I tested in a non unity game, I seemed to be getting 0 - 2 frames delay, which makes me wonder what might be going on. I never seemed to get 3 frame delay in the non unity game though, mainly 2 frame delay, though maybe my tests are just faulty?
Edit - I also did a test with 15 framerate lock, and it seems the input delay was still 3 frames, which means the lower your framerate, the more you will notice the input delay. Its as if for some reason unity needs 3 frames before updating the mouse values (and possibly all input values).
I tried testing keyboard input by bringing up windows On Screen Keyboard, which will highlight the shift key when pressing it, however, it seems the On Screen Keyboard doesnt highlight in time consistently since in my recording unity would react to my input sometimes before or after the On Screen Keyboard highlighted.
Now I too would like to get some input from the people at unity (no pun intended =D).
Maybe this will soon be fixed with the new unity input system?
It states -
“Is it possible to poll input at higher frequency than the frame rate? Not yet but it’s planned. It will be possible to get the input in event form and check the time-stamps of each event. Alternatively it will also be possible to just poll the input state in FixedUpdate rather than Update.”
Very good video demonstration. It is now clear that unity input is lagging behind.
I got no idea why the developers took no time to fix this untill now. It should ve been fairly simple, maybe?
What I notice, is a delay when I start moving the mouse, and when I stop( obviously , its still there while continously moving it).
The video I recorded is quite unprofessional, but you can easily see how much it takes for unity to notice and start moving the camera.The cursor is way ahead of unity camera movement.
However,I decided to test this in Blender Game Engine, which is quite an old engine based off Blender ,and I was surprised of how much more responsive the mouse input felt.Not to mention how crisp it feels in Counter Strike or Call of Duty games.
Hopefully this issue will be solved in the upcoming input system!
I did a test with the new input system, and the issue is still there, so I made a thread about it in the input beta forum hoping it gets more attention there.