[SOLVED] Keyboard.GetState() not working?

Sorry for posting this huge image. So my character refuses to move. I’ve added breakpoints to check if everything is working and it seems so right up to the KeyboardControl() method, in which my variable, “ks”, doesn’t seem to be getting anything. “leftkey” is always false, even if I set it to true, like so, and the character just won’t move. It won’t work if I change the code and use the joystick as the main input either.

What am I missing?

Edit: leftkey becomes true if I set it to true, but the character still won’t move :confused:

First thing: you can make a common method for the region part of the gamepad methods and have each gamepad method you’ve made call that. If you’re copy & pasting code between methods that’s a pretty good sign you’re going about it the wrong way.

What’s the full line for the if statement condition inside the if leftkey / rightkey block? It’s cut off halfway here and might be important.

It goes on like the previous entries. But I don’t think those are so important. Even if I comment them out, it still won’t work.

Edit: pardon me for not answering properly before; I was kind of in a hurry here. so:
About the common method, I intend to do that down the line. I’m keeping it like that until I figure out what’s wrong, so I can properly optimize the code later.

well, you must overwrite it then. Check your gamepad controls afterwards, do they cancel out your keyboard?

Ahh, they do! This was it :expressionless:

I’m trying to make an input-agnostic system, where anyone can plug in a controller, press start, select a character and drop-in on the game, but I couldn’t find any tutorials that would cover it (usually searching for “multiplayer” just returns networking stuff) and can’t quite find out how to do it on my own.

Would you have any tips on how to achieve this?

Yes, the last button pressed determines the active device. Potentially with cool down period. That worked for small platformers.