Change start position of animation

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bobokox
:warning: Old Version Published before Godot 3 was released.

Hey.

I want to change the start position of an animation per script.
I can not find a function for that.

Can someone help me?
thank you

:bust_in_silhouette: Reply From: mark_90

It sounds like the seek method would do the trick.

Example
var start_position_seconds = 0.0
var animation = get_node("AnimationPlayer")
animation.play("your_animation")
animation.seek(start_position_seconds, true)

Do note, that in the example above, we set “true” in animation.seek(start_position_seconds, true). This is because our example here is an animation that we only run once and thus need to restart it.

Thank you.
I had to switch the lines to get it work.

animation.play("anim")
animation.seek(start_pos, true)

bobokox | 2017-06-06 00:30

ah yes. sorry for that. Updated the original answer!

mark_90 | 2017-06-06 07:49