godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

Add copy/paste keyframe functionality to AnimationPlayer editor #3419

Closed lewiji closed 6 months ago

lewiji commented 2 years ago

Describe the project you are working on

A lively, well co-ordinated game that makes frequent use of the AnimationPlayer node.

Describe the problem or limitation you are having in your project

The AnimationPlayer is a powerful multipurpose tool for coordinating mesh and sprite animations, transitions, effects, gameplay elements, function calls and so on. The AnimationPlayer editor has some UX/UI issues around copy and paste. Frequent use of the editor will often have you in need of a copy and paste function for keyframes, wanting to copy sequences of keyframes between tracks, animations, and even other AnimationPlayers. I've, in these instances, sometimes edited the plaintext animation or AnimationPlayer resources by hand to be able to copy and paste values and times, which is easy to mess up and get wrong.

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

The improvements to the AnimationPlayer workflow in https://github.com/godotengine/godot/pull/53689 helps to generalise the functionality of the animation player, and that entails using the editor. Being able to copy and paste keyframes between tracks, preferably with the assigned editor shortcuts for copy and paste (https://github.com/godotengine/godot-proposals/issues/955?), would improve the workflow and allow animation data to be moved around game components in a more flexible way.

This would require some UI/UX decisions, such as what to do when a copy and paste fails between two incompatible tracks: https://twitter.com/reduzio/status/1447898535115038721

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

Copy and paste would need to integrate into the existing editor functionality (https://github.com/godotengine/godot/pull/34892?). Currently, for example, the Duplicate shortcut (Ctrl+d) works in the editor to duplicate keyframes within a single track, rather than attempting to duplicate a node in the scene tree. Similarly, the copy and paste shortcuts should be able to:

I propose that copying and pasting from a single track, to another same-typed track of any animation is the "need to have" functionality of copy/pasting keyframes.

Copying between tracks of varying types is a "nice to have" that could help with the more generalised targeting being worked on in regards to the editor (https://github.com/godotengine/godot/pull/53689) as well as syncing up animations of different components.

If a conversion takes place between compatible track types, this can be made clear to the user, via a non-intrusive info message in the animation editor UI, perhaps in the bottom toolbar, or in the editor output.

A "failed" paste, where the conversion was not possible, could alert the user via a pop up alert box, to make clear via error message that the tracks are incompatible.

Copying from multiple tracks to multiple other tracks is also "nice to have" functionality. The basic copy/paste between single compatible tracks is a huge QoL increase, imo. Adding multiple tracks and type conversions adds a smaller boost on top of that.

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

Feasibly you could write a tool or even external script to manipulate saved animation resources to mangle the data into other files and tracks. But it would be quite a complicated script, I imagine, and not built into the copy and paste workflow of the editor well.

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

This relates directly to the AnimationPlayer editor plugin functionality, and the core copy/paste functionality of the editor.

aXu-AP commented 1 year ago

Are there examples of copy-pasting between tracks of different type? I couldn't come up with anything of real value. There's the obvious int->float->int conversion, and that's not hard to handle (altough comes with possible loss of precision), but what actual properties would realistically needed to copy between animation tracks? Sprite.frame -> position.x?

PGComai commented 1 year ago

this isn't a fix but a workaround I just discovered: if you copy and paste a track you can rename it as if it had the desired target node, and it will switch over to that node. it's not ideal but for now it helps me copy and paste animation tracks between legs on a skeleton I am working on.

DriNeo commented 1 year ago

Is it still impossible to reuse tracks in another node ?

Dancovich commented 11 months ago

Is it still impossible to reuse tracks in another node ?

It's kind of possible.

Duplicate the track (you'll have two tracks in the same node with the same name) and then rename the copy to point to the other node.

Tracks are just paths to a property. If you have a node called Icon and the track is editing it's position, the track name will be "Icon:position". If you rename it to "Gun:position" it will automatically move to the Gun node.

This is just a workaround though. Editor should definitely support this.

CookieBadger commented 6 months ago

Implemented with #87250 and #88350. Can be closed as completed.

Calinou commented 6 months ago

Closing per the above comment. Thanks @CookieBadger for implementing this feature!