0 votes

Im making an animation for my character (png sprites)
and im using a code where character cant stop and run instantly, it takes a second to reach max speed and to stop.
What code or command i need to use to control animation speed, loops per second, while an action(direction) is pressed?
Thank you!

in Engine by (225 points)

1 Answer

+4 votes
Best answer

AnimatedSprite doesn't have a speed parameter, because I guess it's not that common to speed up a frame-by-frame animation. But there is a way:
When using AnimatedSprite, you put a SpriteFrames resource on it, and this one has a speed property: http://docs.godotengine.org/en/latest/classes/class_spriteframes.html?highlight=set_animation_speed
Now setting the speed on the resource will make all nodes using that resource also have that speed, but assuming your character has its own instance of the resource it should be fine.

by (28,833 points)
selected by

don't know why no one upvoted you.. well, cheers.. thanks!

What should i write in setanimationspeed ( String HERE?, float speed )

Try adapting this code:
AnimatedSprite.frames.set_animation_speed("animation_name", velocity)

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 Frequently asked questions and 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.