0 votes

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

in Engine by (91 points)

1 Answer

+1 vote
Best answer

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(startpositionseconds, true). This is because our example here is an animation that we only run once and thus need to restart it.

by (56 points)
edited by

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

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

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.