I have a very simple code that is not working properly.
The code below is in the Update function of my script, which is attached to 3 unique GameObjects:
if (Input.GetButtonDown(myInputString))
{
print(myInputString);
}
myInputString is a private string variable assigned at start. This is a reference to an Input in Project Settings → Input. Perhaps a setting is wrong on there? Picture attached.
When I depress all three inputs simultaneously (currently 0,1,2 on numberpad) not all get logged to the console! Most of the time 2 are logged, sometimes just one. I tested 10 in a row and got 19 messages when I should have gotten 30. Picture attached.
I have no idea where this error could come from. It is the only thing preventing me from finishing my game. Please help!
This could be hardware limitation. Keyboards aren’t actually capable of sending independent signals for all keys at the same time, so if you press too many keys at once some of them get ignored. The exact limit depends on the quality of the keyboard, and certain keys may be treated differently from others (e.g. shift).
But it’s also possible you have an error in your code; it’s really hard to tell without a larger code sample. Your current example doesn’t show handling of multiple inputs (so we can’t tell if you made some sort of mistake in combining them) or the name of the function this code is inside (so we can’t tell if it’s running at the appropriate times).
Maybe? It works perfectly with the xbox controller but not with the keyboard. I have confirmed that it not a limitation of the capability of the keyboard.
I still would like to get to the bottom of the issue for future’s sake, but for the current functionality of my game, it is a non-issue. This game is meant to only be played with a controller of some sort.
You said that you confirmed that it’s not the keyboard by writing some code that works successfully with the keyboard. Doesn’t that mean that you now have working keyboard code? What’s stopping you from using that same working code in your game?
Have you isolated the test code, or have you tested it in your full script that you posted?
Also, even when these keys work, it still does not necessarily mean that it’s not the keyboard. It really depends on the hardware. The wiring / checking can vary drastically for certain keys / key groups.
Check out some keyboard properties like rollover (e.g. on Wikipedia), or anything related to that. It could very well be that the keys you used above (QWE) are differently implemented (i.e. with multi-key-press in mind) on the hardware side, and that the numpad keys are not.