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

Add support for animation sync markers #7476

Open
eddieataberk opened this issue Aug 11, 2023 · 7 comments
Open

Add support for animation sync markers #7476

eddieataberk opened this issue Aug 11, 2023 · 7 comments

Comments

@eddieataberk
Copy link

eddieataberk commented Aug 11, 2023

Describe the project you are working on

TPS game with a complex anim tree.

Describe the problem or limitation you are having in your project

I'm trying to move my project from Unreal Engine to Godot. Everything is working smoothly except for one issue. In Godot, there are no sync markers. It makes it impossible to blend locomotion animations correctly. Even if animations have same length and starting with the same foot blending opposite directions causes a clunky and unnatural motion.

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

The feature that I need exist in Unreal Engine for a long time and it is self-explanatory. But here is the link to documentation
https://docs.unrealengine.com/5.1/en-US/animation-sync-groups-in-unreal-engine/

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

Similar to Unreal Engine in AnimPlayer we add sync markers to our animations.
Markers2
Markers3

Inside AnimTree we select Sync Group, Role, and Method
SyncGroup1

Then System adjusts the playback position and speed based on sync markers.
SyncON

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

No

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

It is about the core of animation synchronization

@Calinou Calinou changed the title Animation Sync Markers Add support for animation sync markers Aug 11, 2023
@TokageItLab
Copy link
Member

To some extent, this can be solved by calculating the ratio from the animation length and setting an arbitrary value to NodeScale(SpeedScale). See also godotengine/godot#62623.

The algorithm by which AnimationTree gets the length of the child animation is rather obscure, so once it is desynchronized, resynchronization becomes quite difficult.

As for the sync marker, do you mean that you want the animation to start at an optional position?

I think that can be solved to some extent by firing NodeSeek at any timing. However, I think it would be better to make it the importer's feature to change the start position.

@eddieataberk
Copy link
Author

eddieataberk commented Aug 11, 2023

To some extent, this can be solved by calculating the ratio from the animation length and setting an arbitrary value to NodeScale(SpeedScale). See also godotengine/godot#62623.

The algorithm by which AnimationTree gets the length of the child animation is rather obscure, so once it is desynchronized, resynchronization becomes quite difficult.

As for the sync marker, do you mean that you want the animation to start at an optional position?

I think that can be solved to some extent by firing NodeSeek at any timing. However, I think it would be better to make it the importer's feature to change the start position.

I am not sure how can we get the current position and length of an animation that needs to be the leader of a sync group so we can use timeseek to match other animations' position? If we can get those values maybe i can work something out from there.

@TokageItLab
Copy link
Member

It is possible to get the remaining time of the currently prioritized animation in AnimationNode with node_blend(test = true), but this is not so convenient since it depends on the internal process of AnimationTree to decide which one is prioritized. This is the same reason:

The algorithm by which AnimationTree gets the length of the child animation is rather obscure, so once it is desynchronized, resynchronization becomes quite difficult.

I don't know if this could be solved by improving the AnimationTree so that each AnimationNode can implement an override for the animation length and start position, but I don't have idea now.

@eddieataberk
Copy link
Author

Yea that would improve things but there are still cases it wouldn't work.

For example: We are changing weapons as a layer to the upper body. weapon sway when walking and running should sync with the lower body. Since we don't know when will player change weapons. even if start position and scales matches they will not sync. We would still need a sync group implementation.

Use case in Unreal:
image

@TokageItLab
Copy link
Member

TokageItLab commented Aug 11, 2023

The current solution in that case is to keep all weapon animations in sync behind the scenes. NodeTransition sync can be enabled in 4.0, so if you are using 3.x, use 4.0 or higher. (StateMachine SyncTransiton is still broken currently)

@eddieataberk
Copy link
Author

Ah, that's neat in that case implementing a custom length and start position would work in most cases.

@eddieataberk
Copy link
Author

	get("parameters/StateMachine/Ground/Locomotion/Moving/WalkLF2D/1/time")))
	set("parameters/StateMachine/Ground/Locomotion/Moving/WalkLF2D/1/time", 0.0)

I find the most efficient way is to get and set time like this. tho it is really cumbersome to do it for all animations. I couldn't find a way to get the length of the animations might need to enter them manually.

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

3 participants