How can I get an interpolated property value from AnimationTree?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By AccumPlus

Animation class have a useful method Variant value_track_interpolate(int track_idx, float time_sec) that returns an interpolated value of given track. But if we are using AnimationTree, animations can be blended. So my question is - how can I get the same interpolated value but for animations blended via AtimationTree? Is it even possible?

I see, that Godot developers using struct AnimationNode.State in cpp, that accumulates all animations with their blend properties as well. But I don’t see any way to get this struct in gdscript without modifying the source code.

By the way, I’m trying to make root motion analogue for 2d.

An animation tree works by blending animations in an animation player right?
I would assume it works the same way regardless of how you use the animation.
Have you tried and came across issues?

zhyrin | 2023-03-16 17:15

I think that AnimationTree uses AnimationPlayer mostly as an animation library and blends animation by itself. Documentation says this:

Playback and transitions should be handled using only the AnimationTree and its constituent AnimationNode(s). The AnimationPlayer node should be used solely for adding, deleting, and editing animations.

As an example of what I want to achive. We have two animations - the first is a looped moving top-down from (0;0) to (0;10) and the second is a looped moving right-left from (0;0) to (10;0). We create AnimationTree with AnimationNodeBlend2, which blends our two animations. So if the blended value = 0.5 te resulted animation will lead to a looped moving from (0;0) to (5;5). So I wonder, how can I calculate this position without running?

AccumPlus | 2023-03-17 08:53