How to animate a 2D sprite sheet

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


I am wonder how I would go about animating a sprite sheet i godot, but I wish the below sprite sheet to move automatically without player input and when the character stops moving then it loads a cut scene.

Sprite Sheet

Thanks in advance

:bust_in_silhouette: Reply From: kidscancode

You can do this with Sprite + AnimationPlayer:

  1. Add your sprite sheet as the Sprite’s Texture.
  2. Set the Sprite’s HFrames and Vframes. Note that now you can set the Frame property to move through the frames.
  3. Add an AnimationPlayer and create a new Animation with a track for the Sprite’s Frame property.
  4. Create keyframes as needed.
  5. Set Animation to “Autoplay”

For more information, see:

Note: Your image link is invalid. You linked to the imgur page, not the direct image link. In your case, you’d set HFrames to 8 and VFrames to 1 to slice your sprite sheet.

Sorry, here is the sprite below:

Sprite Sheet

Kyle J144 | 2019-03-21 15:49

I have done the above but the character will not walk automatically :confused:

Kyle J144 | 2019-03-22 20:31

None of that makes the animation play - that is how you set up the animation. If you want it to play you need to call play() on the AnimationPlayer, or set the animation to “Autoplay”.

kidscancode | 2019-03-22 23:18

The animation is set to autoplay

Kyle J144 | 2019-03-22 23:34