While making 2D games, Godot offers you 2 main ways of drawing animated characters, i.e. the AnimatedSprite node and Sprite node. So, which one should you use? Which is the preferred way?

When I started making games with Godot, I too had stumbled on this problem. What are the occasions for using AnimatedSprite node and when do you go for the Sprite – AnimationPlayer combo. Let’s find out.

AnimatedSprite – Simple but Basic

If you want the simplest way of incorporating animations in Godot, an AnimatedSprite node is what you use.

AnimatedSprite can make use of individual sprite files or even can handle sprite sheets. It is a powerful tool to create custom animations from existing sprite images.

Different animations can be added to a single AnimatedSprite node. For example, different animation sequences for movement in different directions, idle animations, shooting animations etc.

Once different animations have been set up, then using different animations as easy as this:

func _ready()
     var sprite = $AnimatedSprite
     sprite.play("idle")

AnimatedSprite – Pros

  1. Simple to use.
  2. Quick to setup and get it working.
  3. Good for simple animations which wholly rely on sprites. Ideal for enemy characters that might have a handful of predefined animations.

AnimatedSprite – Cons

  1. It’s too simple (ironically) in terms of functionality offered.
  2. Timing of complex animations is difficult.
  3. You cannot call functions from scripts in between animations.

Sprite-AnimationPlayer Combo – A little complex but Powerful

So why do you have to use the Sprite-AnimationPlayer combo?

The other way of implementing animations in Godot is to use a Sprite node which has a sprite sheet with various sub-images. Then you can make use of an AnimationPlayer node as a child node to animate the various sub-images of the parent Sprite node.

It does seem like a round-about way of doing what the AnimatedSprite node was able to do quickly. But, what is the difference? Which is better?

AnimationPlayer node is able to change the “frame” number property of the Sprite. That’s how the animation is achieved. But the quirky thing is, the AnimationPlayer can, in fact, change any property of the Sprite, not just the frame number. This lets you create more advanced animations. For example, you could modulate the alpha value to make the character disappear. Or change the character to white whenever the player takes a hit. All this can be done without the need for additional sprite images.

Moreover, you are not restricted to the Sprite node. The same AnimationPlayer node can control properties of other nodes as well. You can easily control the timings precisely for each animation. You can call functions from within the animations as well with precise control of when it is called in the animation sequence. You can, for example, use this to call a function that makes the jump or shoot exactly when the animation reaches the jump or shoot frame.

AnimationPlayer – Pros

  1. Powerful system.
  2. Precise control on the animation sequences.
  3. Does not rely only on the sprite sub-images. You can modulate various other properties of the sprite to create advanced animations.
  4. Can control properties of other nodes as well.

AnimationPlayer – Cons

  1. It’s a bit too much for simple animations.
  2. Takes a little time to get everything setup.

Conclusion

To summarise, AnimatedSprite node is awesome to use, good for simple animations involving only sprite based animations. AnimationPlayer on the other hand is a powerful tool, excellent for complex animations and not restricted in terms of being able to change various properties of other nodes.

Use AnimatedSprite nodes for characters with simple animations, like enemies and NPC’s.

Use AnimationPlayer nodes for the main character which most likely will have complex animation sequences, especially when timing is important.