I noticed that when I’m running at low fps I get delayed input responses on mouse buttons. For instance if I press the mouse button very fast to shoot a prefab it keeps shooting even after I stopped pressing the mouse button.
This is more noticeable on webplayer builds, the input documentation states that Input.GetKeyDown returns true on the frame the user pressed the key down, but seems like a buffer of my mouse clicks is being created and processed so no click is missed.
This is terrible for my game since I expect players to mash the mouse buttons and this results in the character being locked into the shooting state for a period of time making the game unresponsive.
I’ve uploaded a web player that illustrates this issue.
Sorry if this is a stupid question or anything, I’m sure some of you have encountered this, how did you resolve it? I really need to find a way to fix this, first I thought it was my code, that’s why I wrote the little demo but now that I know it’s a general issue I’m out of ideas.
It’s possible the clicks are queued at an OS level, in which case there’s not much Unity can do that I can think of, although it’s interesting that it doesn’t happen in the editor. Actually it looks like all input is queued: if you click a lot of times and then press the right mouse button, it won’t show the context menu until all the left clicks were processed. Short of “fixing” it by not having a low frame rate, I’m not sure what the answer is.
The clicks might be getting queued by the OS, but if that’s the case I wonder what the unity editor is doing so it doesn’t affect it that much, whatever that is, is what I need to do, any unity devs reading? can you give me a hint?
Still unable to figure this one out and I’m afraid its out of my hands now, without knowing how unity handles its input and how it does it in the editor to minimize the impact on low fps.
I seem to remember back when I learned direct input 9 that you could use buffered and unbuffered input, I’m not sure what unity uses for it’s input or how they initialize it, but if I could just set that to use unbuffered input my problem would go away.
Again without more knowledge I’m just assuming things that are out of my control… What I do need is to fix my game…
Is this something I have to pay support for? Someone from Unity please answer, we really need to get this fixed or have more clarity on the issue.
Thanks Eric and Quietus for their replies, atleast I know I’m not asking something trivial. :?
After some testing with the help of some in the irc channel I found out that this issue is related only to mouse button input, if I do the same but check for the spacebar everything behaves as expected. Any clues?
This issue happens in web player and standalones (macOSX, can’t verify on windows) and it doesn’t happen at all when running the scene on the editor.
I have the same issue in our game - sometimes it gets so serious that the player keeps firing for 10 or more seconds until the buffer is fully dequeued.
I’m sure it’s something simple, and one of the Unity guys can give some input, no pun intended.
I recieved an email form UT, this issue is related to how the unity player for macosx handles the mouse input and will look into a solution on Unity 2.5 or 2.6.
Hi, ratamorph,
I have that same problem in my game, but it’s related to Keypad input. Anyway it’s the same problem, it looks it returns true in ALL the frames the user keep the key pressed and not only on the first frame. Your last post is rather old, did you got some news lately?
Many thanks.
I have this problem when reading the keyboard. I run my input reading in FixedUpdate. I don’t know if that is right or not. When I have high fps, the user input is lost for ever. When I have low fps, the user input is read more than once.
public override void ReadUserInput()
{
if (Input.GetButtonDown("GearUp"))
{
mCurrentGearIndex++;
}
if (Input.GetButtonDown("GearDown"))
{
mCurrentGearIndex--;
}
}
Yeahh this is still an issue. Mouse inputs are lost at low framerates with update and fixedupdate on windows… I’m wondering how people work around this. (2021.3.16f1)
Please do not revive 15 year old threads. Make a new one if you are having a similar sounding issue.
You’re supposed to read input in Update(). As long as you do that, no input events will be lost. Do not read input in FixedUpdate() - it can run more than one time a frame (which will cause you to read same inputs twice) or less than once per frame (which will cause you to miss inputs).