godotengine / godot-proposals

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

Group animations into separate AnimationPlayers while importing model with multiple unrelated moving parts #6682

Open qustrolabe opened 1 year ago

qustrolabe commented 1 year ago

Describe the project you are working on

I am working on 3D game with main focus on jet plane-like moving vehicle. By design it has many moving parts like wings, flaps, thrusters, doors etc. I animate full cycle of their movement in Blender and organize as separate NLA tracks. I plan then use this animation in code with something like .seek() to control their movement.

Describe the problem or limitation you are having in your project

Importing them into Godot 4 creates only one AnimationPlayer for all animations. It for sure useful for character models with simple skeleton-based animation but in my case I can't directly run several animation and control them from code.

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

I suggest to add way to separate animations into multiple AnimationPlayers during import.

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

Importer could search for additional suffix in Animation names (just like -loop for animations and -col, -vehicle for objects) for example: -group1,-group2, -group3-loop So that full animation names will look like:

And imported scene will have AnimationPlayers for each group.

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

This could be worked around in two inconvenient ways:

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

It's importer feature proposal and suggests huge improvement in workflow creating scenes with many moving parts in 3d editors that are compatible with Godot.

RedMser commented 1 year ago

Another workaround I've used is to manually generate and setup the required nodes via a post-import script.

The name suffix stuff is also being replaced with the new advanced import system, and should probably not be extended much anymore. I recommend an approach where you assign a group name to each animation in the advanced import settings instead.

qustrolabe commented 1 year ago

Today I found out that you indeed can actually control that kind of animations via one AnimationPlayer. First of all, you need to set in Advanced Import window in AnimationPlayer in section Import Tracks from IfPresentForAll to IfPresent (to remove tracks that reset position for other objects) and then in code simply do stuff like this:

play("WingsRotation")
seek(my_wings_angle_variable)
advance(0.0)
play("DoorAnimation")
seek(my_door_angle_variable)

It's a good workaround if your object consists only of simple animations that will never actually play (speed_scale always 0.0) and you always set them via seek. But again you would need separate AnimationPlayer if there were for example rotating in loop antenna and you want to both have this antenna animation playing and do some seek()