How to set the animation position in AnimationNodeStateMachine?

Godot Version

4.4.rc1

Question

I want to set the start position of animation playback for a certain AnimationNodeAnimation in AnimationNodeStateMachinePlayback , just like the seek() in AnimationPlayer.

I couldn't find any relevant methods in the document, only the GetCurrentPlayPosition() used to get the position.

my requirement is that when the scene switches, if an animation has not finished playing, I will use the GetCurrentPlayPosition() to record the position of the animation, save it to the singleton(Autoload), and then set the position of the animation in the new scene.

You could try enabling AnimationNodeAnimation.use_custom_timeline and modifying the AnimationNodeAnimation.timeline_length and AnimationNodeAnimation.start_offset

Thank you, I tried setting the use_custom_timeline property of AnimationNodeAnimation in the editor, and it did work, but I don’t know how to get AnimationNodeAnimation from AnimationNodeStateMachinePlayback or AnimationTree in the code.

This is my animationTree. For example, how can I get the AnimationNodeAnimation for the ”dodge“?

This is not a parameter that gets exposed to the AnimationTree node so you’ll need to use the different methods to get the nodes each AnimationNode has like AnimationNodeBlendTree.get_node() and AnimationNodeStateMachine.get_node() until you reach the AnimationNodeAnimation you want to modify.