My game supports touchscreen, keyboard + mouse and the Xbox One controller and the input so far works properly. Now I also want to add a second layout for the gamepad the player can then pick in the settings, e.g.:

Layout 1: Fly up with "A", fly down with "B" (so two buttons)

Layout 2: Fly up with "LB", fly down with "LT" (LT uses an axis, not a button!)

With keyboard/touchscreen and gamepad input I was able to create two different inputs in Unity's InputManager for the same thing and they would then trigger depending on which input device you're using.

I thought about adding a bool for the layouts and checking it every time a button is pressed but that sounds more like a quick and dirty solution. Descriptions of InputManagers I've found so far make it sound like they're used for rebinding keys or to support different gamepads (e.g. Xbox One and PS4), which I don't want/need (plus, these InputManagers are usually pretty expensive).

How do you handle actual different layouts that use the same buttons/axis for different things, especially with something using a button in the first layout and an axis in the second?

  • I'm still looking for an answer! In the meantime I've "solved" it the way I originally didn't want to do it: I created 2 inputs for every button (1x gamepad, 1x keyboard) and check a bool if gamepad layout 1 or 2 is active, then choose the according functions. The only thing you really have to be careful with is actually using the right input and distinguishing between button and axis, since the former returns a bool but with the latter you have to check for >0/<0. – Neph Oct 22 at 11:30

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.