Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to group input actions #4910

Open
OverloadedOrama opened this issue Jul 18, 2022 · 5 comments
Open

Add the ability to group input actions #4910

OverloadedOrama opened this issue Jul 18, 2022 · 5 comments

Comments

@OverloadedOrama
Copy link
Contributor

OverloadedOrama commented Jul 18, 2022

Describe the project you are working on

Keychain, a Godot addon that lets players change the input action bindings of the game/software, Pixelorama, a pixel art editor, and various game projects.

Describe the problem or limitation you are having in your project

For projects with a lot of input actions, the input map in the project settings can become very messy and hard to iterate, scroll, search for specific actions and to organize them by category. Here is an example from Pixelorama's input map.

2022-07-19.00-09-53.mp4

Describe the feature / enhancement and how it helps to overcome the problem or limitation

The ability to group certain input actions together. Groups would appear in the input map and the content of each group can be collapses for easier scrolling. Sub-groups (groups inside groups) should also be possible.

Apart from being a QOL improvement for developers, it would help end-users/players, since the developers could just get the groups from code to categorize exposed actions for the players to modify. Without this, developers have to code their own logic for InputGroups, and group input actions manually, which is what I have done with Keychain, resulting in messy code for something that is better done from the input map UI.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

In the input map, a new text field and button for creating groups can be added, directly below or above the action text field and "Add" button. Simply dragging and dropping actions into groups and groups into groups to categorize them should be good enough. The ability to get the groups and what they contain via the InputMap singleton would be necessary, too, although I am not sure what exact implementation would be best.

It could look something like this.
image

Image taken from Pixelorama using the Keychain addon.

If this enhancement will not be used often, can it be worked around with a few lines of script?

I don't think so.

Is there a reason why this should be core and not an add-on in the asset library?

I am not sure if addons have the ability to edit the input map in such a capacity. And even if they did, I think it would be a better experience overall if Godot had this feature by default, as it is a nice quality of life feature to have.

@Calinou
Copy link
Member

Calinou commented Jul 18, 2022

Like project settings, I suppose this could be done by allowing / to be used in input action names, and using this to create groups in the InputMap editor.

The downside is that it becomes less obvious how to access a specific input action via code, especially if we decide to use automatic capitalization for group names (let alone input names).

@Calinou Calinou changed the title Ability to group input actions Add the ability to group input actions Jul 18, 2022
@OverloadedOrama
Copy link
Contributor Author

Since input actions don't currently have automatic capitalization, it would probably be better if groups don't have either. We also need to ensure that group names can have spaces, including trailing whitespaces. Names such as " valid " are acceptable as input action names (checked both 3.x and 4.x), so to ensure compatibility we should probably keep them that way, and for consistency purposes, group names should work the same. From what I see, project setting names do not allow for spaces.

That being said, if / can work with spaces, it sounds like a good idea to access input actions like this via code. Actions that are grouped could be accessed by typing their path (e.g. event.is_action("group1/group2/action name")), and ungrouped actions can be accessed the same way they are now. That way we could avoid adding more methods to InputMap, or modifying already existing ones. It could also allow for having multiple input actions having the same name if they are in different groups, but we would need to check if the user is attempting to put two same-named actions in the same group, and prevent them from doing so.

But I think for the editor, having a dedicated button and text field for groups would help to make the fact that groups exist more obvious, and their creation process more intuitive.

@lucianamerege
Copy link

I know this is a year old, but it would be so helpful! It would simplify the code so much when checking for example if the player is supposed to be moving.

@etiennePerriere
Copy link

Hello there.

Pretty new to Godot and not yet sure if I can or cannot do what I want now nor if these suggested feature would help me with my need (but it definitely looks like), so I'm just giving my case to illustrate the need for this feature.

Let's say you have 3 input actions "cast_a", "cast_b", "cast_c" which you can combine (cast a+b / a+c / b+c / a+b+c). Then you want to do something when any of those is released. It would be great to have a "cast" action group to do something on any "cast" and not having to explicit each input and combination for one same result.

This behavior would combine well with the grouping in the InputMap settings.

@Cronos87
Copy link

Something I do love about Godot is the simplicity of setting up inputs with Input Map. Sadly, as this proposal pointed out, it becomes hard to maintain on larger projects, and the grouping feature would be such a great addition.

It could be something like the inspector using the new export category or group feature.

I'm looking forward to seeing this feature one day 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants