0 votes

Hi, I'm trying to modify the speed of an AnimatedSprite.

        AnimatedSprite sprite = (AnimatedSprite)GetNode("sprite_name");
    sprite.Play(animName, false);

That works well, but not this:

sprite.SpeedScale=0f;

I also tried this but it doesn't work either

sprite.SetSpeedScale

Is there anyway to manually modify the speed of the sprite? It's a very basic task in my opinion, it can't be that hard...

in Engine by (17 points)

1 Answer

0 votes

SpeedScale seems to be the property to use, I don't know why it doesn't work for you.
SetSpeedScale is the same as assigning SpeedScale (it's just the internal setter used in the property).

You could also change Frames.SetAnimationSpeed("Anim Name", speed), but if you re-used the same SpriteFrames resource elsewhere (or duplicated the node) it will change it everywhere it's used.

Note: setting SpeedScale will have no effect if the animation is not playing already. i.e doing SpeedScale = 1f will not start the animation, and 0f will not stop it.

by (29,042 points)
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 [email protected] with your username.