Open me2beats opened 2 years ago
Just a simple example:
I needed to copy a character from one project to another.
I copied the scene.
But then I also had to copy-paste input actions and events.
I solved it by copy-pasting [input]
section in project.godot
.
I closed the project first to avoid conflicts.
this is not so handy. And the case was easy, it would be harder if I would need to copy only several actions to a project that already has something in [input] section
Having a proposed feature implemented, I could just copy the scene, and input events would appear in the new project automatically (if the character scene node has input_map_override
Describe the project you are working on
a 3D game
Describe the problem or limitation you are having in your project
I test different FPS templates in my project, for example AssetLib templates. A problem I can see is what often in these templates there is a code in
_physics_process
and_input()
likeis_action_pressed("action_name")
that requires to manually add actions and bindings which is not handy, I would say even a bit annoying to add them, then if you don't find the template useful, delete them etc. The list of actions used in a template may be quite big.Another problem is sets of actions with overlapping events. If you have different types of movement in the game like
then you can see that actions are different but some events overlap for example
Key S
:And if you have all 3 actions (run, drive a car, drive a helicopter) in the
InputMap
, they all will be emitted/triggered, which means you need to do extra if else checks (like "if the player is running"). Or you can add/remove actions and events from the code, which is not handy.Describe the feature / enhancement and how it helps to overcome the problem or limitation
I suggest adding
Node.input_map_override
property. Any node added in the game will automatically add actions and their events (keystrokes, mouse clicks etc) defined in that property, to InputMap. And the actions can be also automatically removed when the node exits the tree (there can be an option for not doing that, see below).Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Say I create a node KinematicBody, then I write some code, for example for FPS movement, then I go to Inspector and set
input_map_override
property - I just add the actions likemove_forward
,move_backwards
,move_left
,move_right
,jump
,reload
,interact
etc and add events like keystrokes WASD. The I run the game and I have these actions added to InputMap (default actions and actions defined earlier ofc remain).InputMapOverrides list should be added as well because you don't want to open each scene and select each node to see where an action was added. From that dialog you can see all InputMap overrides for all scenes. It can be implemented as a Tree node like
It may or may not be read-only (I prefer not). Anyway there sould be a button to go to the selected node to set InputMap overrides from there.
There should be a checkbox like:
remove actions on exiting tree
that means - should actions be removed from InputMap when you remove the node from the tree /queue_free() it (in the running game)? in many cases you want the actions defined in a node to be removed from InputMap automatically then the node exits the tree, especially when having actions with overlapping (conflicting) events (see problem [2]). But there can ofc be cases when you already have action X in the InputMap, and you don't want it to be removed by nodes, that's why I think the checkbox can be added. Additionally there could be a way to completely forbid auto removing an action when the node exits the tree but this feature wouldn't be used often in simple projects.code completion for actions: I think it's fine to just give list of all InputMap actions overrides existing in the project (in any node of any scene).
Anyone can ofc completely ignore that system and keep using InputMap to add actions directly - manually or from code, or combine these 2 approaches.
If this enhancement will not be used often, can it be worked around with a few lines of script?
you can solve [2] (overlapping events), but not [1] (a need to manually add actions and bindings for many nodes added from AssetLib or other places). Actually [1] cannot be solved completely, some asset/template creators will ignore the feature anyway. But I still think this feature would be used often.
Is there a reason why this should be core and not an add-on in the asset library?
I think having it as an add-on will be quite hacky, and still, this wouldn't solve problem [1]