- Home /
Input sometimes delayed
I exported my game to EXE and WEBGL, and sometimes when you press a key, the input doesn't trigger. It makes the game harder and it's just overall very annoying.
In what ways are you checking for and utilizing Input? You mentioned in another comment that you're using Input.GetKey(), but what function is that called from? When the key's checked, how is it being used? Is it a complete lack of behavior or is it inconsistent behavior (e.g. an impact that could vary based on framerate differences between editor and build)?
Answer by GamerLordMat · Aug 13, 2021 at 08:04 PM
Are you testing in Update or FixedUpdate?
For any immediate input tests (GetKeyDown() and GetKeyUp()), this is a bad idea, since those can be missed entirely by asynchronous ti$$anonymous$$gs of Update() and FixedUpdate().
That said, it's still "wrong" to use FixedUpdate() for Input.GetKey() (and similar) as well, so you should move your logic for input into Update() in general.
I originally had it in Update() but when it's put in Update() the camera would jitter because the character's movement is based around Rigidbody2D, if I switch it back it's be all jittery again. Is there any way I could put it in Update() without it being Jittery.
Also, Interpolate doesn't work for me
Also note that Fixed Update goes with a framrate of 50 frames per second; that is pretty slow alone but the operation system has some delay too. But that is not noticeable (I've done some simple experiments with Input delay 50 ms delay is totally fine)
Also, you can set the fixed update rate (not really accurate to call it a frame rate) in your Edit>ProjectSettings>Time section. So you could make it 60, or even 120 if you wanted (though depending on the demands of your physics interactions, you may not be able to keep that rate consistent)
Answer by adimac93 · Aug 13, 2021 at 10:02 AM
@Skeeall13 Maybe that can help you: Input values are floats between -1.0 and 0.0 / 1.0 and 0.0. If you are checking for equality there can be a problem. Try using >=, >=.
I use
If (Input.GetKey("Z")){ // do something }
So that cant work but thank you for the response
Your answer
![](https://koobas.hobune.stream/wayback/20220613041554im_/https://answers.unity.com/themes/thub/images/avi.jpg)