Hi folks, I'm running into a brick wall here and I hope some of the more experienced C2 users can give me some insight into how to fix this issue. Here's my situation:
- Four-player co-op game, using keyboard and/or gamepads.
- Character selection screen before the game kicks off.
- In this screen, I want to give players the chance to pick up any gamepad and press A to join in. I want them to be assigned a player number based on the order in which they join.
I've got the game working so that player numbers are assigned based on the controller number, so P1 can be keyboard, P2 can be gamepad(0), P3 is gamepad(1), etc. Or P1 is gamepad(0), P2 is gamepad(1) and so on. All of the controls are set up so that it accepts input from any source, then passes that input along to a set of generic functions that actually make the players move.
The trouble is, there's no generic "On any gamepad, any button pressed" event, nor is there a way to record a controller number when a button is pressed. This means that players will need to join the game in the order that gamepads are assigned by the OS, not the order in which they press the A button. This is what I'm trying to avoid.
I'd like to use the logic "When Up is pressed on controller(Player/ControllerNumber), move Sprite(Player/ControllerNumber) up", but I can't figure out how to match a player to a controller in a dynamic way.
I hope this makes sense, and I hope someone can assist!