The hell of controlling AnimationTree node with GDScript

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

Hello,

In my project I have to play imported from Blender animations (BOTH TRANSFORMS ANIMATION AND SHAPEKEYS) simultaneously.

My scene contains:

mesh (MeshInstance, is the one for the tree animation)
AnimationPlayer (sets as AnimationPlayer of tree node)
AnimationTree

The problem is that after adding node AnimationTree and making it as TreeRoot AnimationNodeBlendTree in this form:

Animation (shapekeys) —>
Blend2(blend_amount set to 0.5) —> TimeScale —> Output
Animation (transforms) —>

(Allowing me to play both animations simultaneously and control their speed)

I don’t know how to set up everything correctly for both animations to start from the beginning.

If the code doesn’t set anything at all, the initial state of animations is almost random (not the first frame).

If I set it from the code like that: (In Ready function)

AnimationPlayer.play("pageturn-shapekeys")
AnimationPlayer.seek(0, true)
AnimationPlayer.stop()
AnimationPlayer.play("pageturn-transform")
AnimationPlayer.seek(0, true)
AnimationPlayer.stop()

This initial state is close to what it should be but it’s not perfectly 1 frame of both animations.

The interesting thing is that when you put the whole tree back and forward play, like that:

AnimationTree["parameters/TimeScale/scale"] = 1
AnimationTree.active = true

and after finish:

AnimationTree["parameters/TimeScale/scale"] = -1
AnimationTree.active = true

The first frame is correct.

The latest stable Godot and the latest stable Blender, I transfer data using GLTF (separated) and import with separate objects+materials+animations.

So how to set the animations to ALWAYS start from the beginning in this configuration?