Cross-Platform Input
How best to handle differences between Input when publishing a game cross-platform? I am trying to handle input from an Xbox 360 controller, but the buttons and axes are handled so differently from OS to OS that it seems unmanageable. And I can't seem to find an easy way to swap out the InputManager depending on the current platform. Any thoughts?
Answer by pRoFlT · Aug 24, 2015 at 05:08 AM
I'm dealing with this for my app right now.
so far i have a playerController.cs class and use #IF UNITY_ANDROID or #IF UNITY_STANDALONE
these are compiler statements and will block out code from being compiled to these systems.
I dont have any good examples but you could develop a controller class that has the functionality you need and then write separate controls for Playstation and XBOX. That is just an idea.
I know there are controller settings built into unity that are meant to help with this kind of thing. maybe you should do some more searching online as someone has surely come up with an answer better then mine. :)
here is something https://www.youtube.com/watch?v=uPrqvisEdpU
or you could buy an asset --> https://www.assetstore.unity3d.com/en/#!/content/5713 $10 bucks. i wouldn't pay it myself. but if you are struggling maybe it is an answer for you.
heres one for $30 https://www.assetstore.unity3d.com/en/#!/content/14695 looks nicer.
Answer by tfunk · Aug 25, 2015 at 05:07 PM
Thanks! I guess I was hoping I wouldn't have to have code filled with a bunch of compiler macros, but I guess that's just the way it's done?
So it seems like these addons are circumventing the default InputManager altogether? I'll do some digging into these and keep my eyes out for something else too...if possible I'd like to still use the InputManager Unity provides, as it hooks up easily with the UI system and all that jazz..
Answer by sutartmelson · Dec 18, 2016 at 10:02 PM
I wrote some c# code to manage xbox controllers across multiple platforms. I think it does exactly what you're looking for. Try it out and contribute if you can improve it!
Your answer
Follow this Question
Related Questions
UNITY no longer detecting XBOX360 controller input,XBOX 360 controller no longer working with UNITY 0 Answers
CrossPlatformInput GetAxis("Vertical") behave differently from Input.GetAxis("Vertical") !? 0 Answers
Do I need to use the Input Manager to register all input axes? 0 Answers
JoyCons not working with vJoy 0 Answers
Axes in the Input Manager are blank 1 Answer