Is there any way to animated sprite?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Radgrid728

I want an animated sprite to stop it’s animation by pressing a button.
So I wrote a script
func _on_Button3_pressed():
if Input.is_action_pressed(“Your Button”): $“stop”)

But nothing happened. What should I do?

:bust_in_silhouette: Reply From: Wakatta

$AnimatedSprite.stop() is what you’re looking for as what your code actually does is tell $AnimatedSprite to play an animation named “stop”

Something to be mindful of is that stop() does not reset your animation

Just for you to know, you can pass a bool to reset or not the animation while calling stop(). It’s true by default, see AnimationPlayer — Documentation de Godot Engine (4.x) en français

MrEliptik | 2021-03-21 10:25

Nice adage also good knowledge to have.

Wakatta | 2021-03-21 18:04