Input.GetAxisRaw(“Horizontal”) will return the value of that axis. That axis is for either “all joysticks”, “joystick 1”, “joystick 2” etc (as specified in the Input Manager).
But, how do I set to “all joysticks” and then, in the code, get each value for each joystick?
I could add a “Horizontal1”, “Horizontal2”, “Horizontal3”, etc. and for each set it to “joystick 1”, “joystick 2”, “joystick3”. But the problem with this is… I have to create 16 of them if I want to support 16 controllers… and also I am then limited to 16 controllers.
I want unlimited controllers to be able to connect to the game, how do I do this? If I have to create 16 separate axis, that is ridiculous.
P.S A lot of people seem to be creating there own “Input Manager”, and that is what I would like to do, but can’t figure out how.
I couldn’t tell you, but I’ve heard good things about this asset - and perhaps you could use it or at least learn from it by figuring out how they did it (I think they offer multi controller support):
Yes, that’s one of the problems, but it’s not the worst problem. The worst problem is that most controllers have more than one axis and there is no consistency in the way they are numbered (eg axis one may be the d-pad for one controller but an analog stick on a different one). This exact problem applies to the buttons too.
Unity may point you towards the Input Manager to define the controls for your game but the truth of the matter is it’s completely worthless for any situation where you can’t guarantee that the user will always have a controller with a very specific layout.
Unity is working on a solution in the form of a completely new Input API, but until that’s been released your only options are to either create your own framework for handling input (it’s way easier than it sounds), or purchase one made by a third party like Rewired.
For basic information on how to create your own framework, check the link below.
Yep definitely I preference and suggest, to create own input system, with mapping IO.
If done correctly, you can map easily for example forward movement to axis, keys, mouse, or other inputs.
That way you can load your inputs configuration even from text file.
Keeping inputs in one place. Preferably in same class.
Don’t call Input somewhere inside your game, as these become scattered and harder to maintain.
I use something very similar to this for my own configurable input systems. It works well on small games. But it still does feel very archaic. It doesn’t for example let you automatically know which inputs are coming from which controller. Which means that if anyone plugs in a new device, you still have to go through the set up process.
Highly recommend the asset store for solutions. Rewired is popular.
SteamVR is on the right track with their input abstraction. You define actions then you can bind these to default bindings and player can override those. A action can be Boolean, single, Vector2 and even skeleton (gesture based).
Unity should look at how they did it, though it needs some more work. Because with great abstraction comes great responsibility. For example I miss a binding conflict API and a way of getting the binding as a text so I can present in Tutorial and UI.