The “tl;dr” question about input, could be: Which is the best way to manage several players (up to 4), each using its own Xbox 360 controller, in Unity?
The long version follows:
As the tl;dr says, I’m trying to manage 4 players in the same screen. I read some time ago about the input manager that Unity uses, but read somewhere that it was really buggy, and that its better to write your own, so thats what I did.
I have my “inputController” which receives a set of pre-configured keys (originally from keyboard) and asks about Input.GetKeyDown(key), Input.getKeyUp(key) and so. The characters moved along right and everything was nice.
Then, I “upgraded” it to read also axis from a joystick (Input.getAxis(“AxisName”+playerNumber)). Using a custom set of keys (joystickButton) I managed to get one pad working to move a second character, using 4 buttons, the left thumbstick and the triggers.
So, the InputManager has now 4 “custom” axis: 2 for the thumbstick (horizontal and vertical) and the other two for both triggers.
My first problem is that I don’t know how can I control a second pad plugged in the same computer. For what I’ve seen here, for the buttons is easy as “joystickButton”, where “n” is the number of the player (i.e. “Joystick4Button0”). The real problem comes with the axis. As I’m reading them from the “custom axis” I make in the Input inspector, do I need to set up 4 custom axis for each new player, and make each player “read” the designated axis? can I have several “Inputs”, each copy of the other, but with different bindings?
The second problem is that what I’ve seen in the documentation is puzzling me now: It seems that the idea is to allow the player redefine the controls through the “Input” tab on the start menu, but, of course, what I’m doing kind of overrides it completely. Is Unity’s standard Input handling reliable enough to be used, should I convert my class to work with it or I’m better handling everything by myself and not paying attention to this module?