godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.13k stars 93 forks source link

New "Invert" or "Remap" AnimationTree node to flip animations on X axis #8951

Open vaner-org opened 8 months ago

vaner-org commented 8 months ago

Describe the project you are working on

I'm working on a project that relies heavily on animations being tied to the footstep they are triggered with, which means mirrored animations for the left and right side of the character.

Describe the problem or limitation you are having in your project

More often than not, I have to either bake via Blender a mirrored animation for either side, or have the animation be duplicated and flipped upon import by a Godot script.

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

An "Invert" node that consists of a simple on/off switch, or blending the placement between all the bones marked "Left" with parallel bones marked "Right" would go a long way towards helping me have fewer baked animations and a lower overhead both on the Blender and Godot side of things.

This proposal could be generalised further into a "Swap" or "Remap" node that would allow one animation's filter set to be traded with another, using defined parameters (for instance, ignore "Left" and "Right" on both set's bone names to facilitate the swap)

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

Either this: invert

Or this: swap

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

It can be done upon export/import but will double the size of animations packaged with the game, when it can be accomplished trivially via code.

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

I feel that it should be a core since it does simplify character animation work quite significantly, and targets a very common use case for games.

Mickeon commented 8 months ago

I like this. There have been similar proposals but they are too specific for the user that proposed them. Clearly there is a need. This feature as an AnimationNode over a "magic" toggle would make a lot of sense.

The actual implementation may be different in practice but it's a good idea, at least at a glance.

AThousandShips commented 8 months ago

See also:

TokageItLab commented 5 months ago

I assume if you mirror the animation dynamically with an AnimationNode, it should cause a confusion about the trackpath. So basically, it should be complemented by the editor's option to create a mirrored animation like https://github.com/godotengine/godot/pull/89070.

Also it should be possible to expand on this by combining it with the resourceization of the filter to make filter usable anywhere like https://github.com/godotengine/godot/pull/76788.