Search Unity

What is CrossPlatformInputManager for?

Discussion in 'Scripting' started by eneroth3, Dec 20, 2018.

  1. eneroth3

    eneroth3

    Joined:
    Oct 22, 2018
    Posts:
    63
    I've begun to edit the FirstPersonControleller script from the Standard Assets asset to suit my own needs. The complete lack of documentation of its CrossPlatformInputManager class has caused a bit of frustration to say the least. It's not covered on the Unity website as it's apparently not a native part of Unity, and with no documentation whatsoever in the .cs file itself saying its design is based on the native Input class I it took me some time to find there even was such a class. I had the impression this was _the_ way to detect user input, not merely an additional layer to it.

    I could go on ranting about my experience with CrossPlatformInputManager, but to get to the point, what is it for? The name suggests it works on more platforms, but the inputs used are defined in the native input manager, are they not (Edit > Project Settings > Input)? What does CrossPlatformInputManager do that Input doesn't? Are certain axes' names hardcoded to certain inputs on other devices, such as tilting or swiping? Or are these set up from some place other than the native InputManager?

    What is CrossPlatformInputManager for and is it worth the trouble to try to figure this out?
     
  2. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,531
    So it's been a while since I ever looked at FirstPersonController... but I'm willing to bet I know what's going on with this class.

    See the unity Input system is hot garbage!

    When you go into the input manager through the menu and configure your inputs. Well, the index/id that is button X on an xbox controller isn't necessarily the same button on a PS4 controller or any other controller.

    Furthermore more what is button X on Windows isn't button X on Mac or Linux.

    You actually have to reconfigure your input based on what platform you're targeting.

    ...

    Or, what most people do is implement their own input system. Sometimes either wrapping the existing system by having generic input titles for each input and having some table map the correct inputs on a per platform/controller basis (which is what I bet CrossPlatformInputManager does). Or people even use their own custom hook into the OS/platform (way more complicated and usually requries custom libraries for each platform).

    It is definitely worth it looking into how to deal with this issue from platform to platform.

    As to if CrossPlatformInputManager is a good example... I have no idea. Personally... I doubt it. But then again, I find a lot of the 'Standard Assets' lacking.
     
    eneroth3 likes this.
  3. eneroth3

    eneroth3

    Joined:
    Oct 22, 2018
    Posts:
    63
    If the original class is a mess I wish they didn't just pour more mess onto the mess so you can't easily see where one mess ends and the other mess starts. That just makes the mess messier :( .

    Your impression of the standard assets seems quite similar to my impression of much of the training material. In some videos it's stressed how this is just "one way of doing it it", and in the comments people point out tons of bad habits and code smells. In the end such material just makes me more confused.

    I wish there was more focus on creating high quality material, that can set an example for the people using it.