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

Allow AnimationPlayer.play("new_animation") not to stop previous animation unrelated tracks. #7610

Open
jcarlosrc opened this issue Sep 5, 2023 · 2 comments

Comments

@jcarlosrc
Copy link

Describe the project you are working on

A 3D game.

Describe the problem or limitation you are having in your project

The default AnimationPlayer behavior causes a lot of trouble when dealing with animations involving many tracks. Everytime we call the play("new_animation") method, the previous animation is completely stopped. Even tracks that are not keyframed on the "new_animation" are stopped. This causes having to create an AnimationPlayer for each property if we do not want a track being stopped by other unrelated tracks.
In the project attached, we have animationLeft animating only the left square color. AnimationRight animates the second square color. If we call play("animationLeft") followed by play("animationRight) we would expect the left square to start animating and then the right one to play its animation. However, playing "animationRight" stops the animationLeft. This becomes a big problem if we animate many properties. Any small animation completely stops all other tracks in the AnimationPlayer.
In the video, we first see the current behavior of the Animation Player. Then we see the desired behavior, achieved with an animation Tree and a animation blend 2 node with filter to On. We have the project file also for testing.

godot_animation_blending.mp4

AnimationBlending.zip

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

Currently, there are two ways to overcome this limitation:
a) Creating a single animation player for every property that we want not to be stopped by other tracks. This may require making many versions of the same animation , one for each Animation Player created. And call play() for each AnimationPlayer.
b) Using an Animation Tree and create a single Blend2 node for every animation and set the filters enabled to select only the tracks that we want to apply. If we want smooth transitions, this also requires creating variables and setting lerp methods on the process function.
Both solutions are not ideal, causing a lot of work if there are many properties involved.
We could implement a boolean switch to allow the play("new_animation") call not to override previous tracks if such tracks are not part of the new animation. Only keyframed tracks would override the current playback. If the play("new_animation") is the first one, then we can use the "Reset" animation or the default values as a the value to start from. This does not need to be the default behavior but optional to avoid the need to create a lot of animation players. Previous $AnimationPlayer methods would remain related to only the last play("animation") call.

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

It could be calling play(animation = "new_animation", blend_time = -1, speed = 1, from_end = false, override_unrelated_tracks = false) to say that we do not want the new animation to interfere with the previous unrelated tracks. The default value should be true to avoid conflicts with previous versions.

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

It is a core feature.

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

This is a core feature.

@jcarlosrc jcarlosrc changed the title Allow AnimationPlayer.play("new_animation") to blend **only** keyframed properties. Allow AnimationPlayer.play("new_animation") to blend only keyframed properties. Sep 5, 2023
@TokageItLab
Copy link
Member

Closed by godotengine/godot#80813 as Deterministic option.

@jcarlosrc
Copy link
Author

The new "deterministic" option cannot be considered an implementation of this feature. The main main purpose of this proposal was the ability of letting the tracks of previous animation to go on animating if the new animations do not have such tracks keyframed. As per the current implementation, the previous animation still stops regardless of being or not deterministic. If it is deterministic, the new animation uses the Rest frame. If it is not, the new animation uses the last frame value of the previous animation. In both scenarios, the previous animation is stopped at a static frame.
It appears the required behavior can be achieved using filters in an Animation Tree. However, I think that it should be an option to have that blending behavior in Animation Player.

@jcarlosrc jcarlosrc changed the title Allow AnimationPlayer.play("new_animation") to blend only keyframed properties. Allow AnimationPlayer.play("new_animation") not to stop previous animation unrelated tracks. Mar 22, 2024
@Calinou Calinou reopened this Mar 26, 2024
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

4 participants