Input.Get______Down is not registering every press...

I have a script attached to a GameObject that literally only has the Update function kicking out a Debug.Log if Input.GetButtonDown(“Fire1”) or Input.GetKeyDown(KeyCode.Space) or Input.GetMouseButtonDown(0) is true. Thing is I can press the inputs 10 times over 5 seconds and only register 2 presses. It’s not uniform (sometimes the result is 7, sometimes its 4) but it’s never press for press. I know I’m not running less than a frame per second so does anyone have any info on this?

You sure you used Update and not FixedUpdate for example? Can you show your code?

2 Likes

Try to set application frame rate to something realistic. I don’t know if it’s possible but having too fast of a frame rate may register some of those presses under get key instead. I’m not 100%. But if you didn’t consider that maybe you are running 250-1000 fps and keypress isn’t registering as it should then maybe give it a test and check results.

run key down, get key and key up with unique debugs at a relative frame rate for the same key.

if it’s not the issue. Maybe it’s the specific key is getting screwed on your hardware.

To go deeper into what PraetorBlue is suggesting, Input doesn’t actually ‘update’ until Update is called. Since FixedUpdate and Update are not in sync, if your Input detection is in FixedUpdate, there may be certain times where you miss a GetKeyDown check.

Here’s a poorly drawn sketch.

8388549--1106565--upload_2022-8-25_0-41-25.png

1 Like

Upon closer inspection, I was calling in FixedUpdate. That’s my fault people, thanks for the quick reply.

1 Like