Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Feedback A neat feature for Input System

Discussion in 'Input System' started by INeatFreak, Dec 2, 2021.

?

What do you think about this approach?

Poll closed Mar 2, 2022.
  1. It's a must feature

    100.0%
  2. It's a good suggestion

    0 vote(s)
    0.0%
  3. It's unnecessary (please explain why)

    0 vote(s)
    0.0%
  1. INeatFreak

    INeatFreak

    Joined:
    Sep 12, 2018
    Posts:
    46
    The new Input System sure is a lot more modular but it turns into spaghetti rather quickly on big projects with lots of ActionMaps.

    I think making Actions a seperate .asset file that can be shared across ActionMaps can make things a lot easier. Currently Actions only exist inside ActionMap. To share Action between different maps we need to duplicate same Actions and maintain them as the project grows.

    Example: Let's say you can chat while both Vehicle and Character (or etc) ActionMaps are active, with current approach you would have a "Chat" Action for each map which is not ideal. But with suggested approach you only need one Action with "Enter" key set as Input, even when saving/loading user modified inputs it's easy to do because there's only single key for chatting.

    + Another good thing about this approach is that we can just reference that Action asset ("ChatAction.asset") from any script (ChatSystem.cs for example) and it doesn't need know about the whole input system, just reference the action from script and subscribe some method(s) to it.
     
  2. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    10,079
    No. The proper way is to have a general action map with all the actions doesn't change when you swap vehicles and have vehicle-specific action maps to enable/disable specific actions.
    Which means you should define the chat button only once and keep it separate from your Vehicle and Character actionmaps in a "General Gameplay" (or you can call whatever you like) actionmap. Same for things common between (pause)menus and gameplays.
    You can have as many actionmaps as you need to describe your specific situation.
     
    JoNax97 likes this.
  3. INeatFreak

    INeatFreak

    Joined:
    Sep 12, 2018
    Posts:
    46
    That will work until it doesn't. There will be eventually be a point where it's too specific to put into categories like "General Gameplay". It's more intuitive this way imo.

    This is a really weak argument, point is to reduce that count not increase it.
     
    AurochJapeth likes this.
  4. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    10,079
    But why would you reduce it and generate a lot of individual actions? Besides, you can already do that outside of the InputActionAsset. I don't see the usefulness here, but you do you, of course.