Input Issue

Hi, while scripting for NumberWizard game, when I press the up/down arrow once, it takes it as two inputs instead of one. I’m using Input.GetKey(KeyCode.UpArrow) and Input.GetKey(KeyCode.DownArrow) for the respective inputs. Would really appreciate if someone points out the problem.

Input.GetKey keeps returning TRUE while the key is pressed. so you will end up with it running multiple times.

However, you could use Input.GetKeyDown instead. This will only return true on the frame it is pressed on, so it will only get called once, until it is released and pressed again. should get rid of it being called multiple times in a row.

Thanks a lot.

No worries, let us know if that gets it working properly for you.

Yeah it worked absolutely fine.

1 Like

I think it might actually be responding to both the KeyDown and KeyUp events

Privacy & Terms