What is the difference between a Tween and an AnimationPlayer?

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

Hello everyone,

I’m new to Godot and have started making a platformer.
To animate my sprites, I am using AnimatedSprite node or sometimes the AnimationPlayer node when I need to animate a property of a node.

In the course of researching for the same, I ran into something called a Tween, which, admittedly, I don’t quite fully understand yet.

I apologize in advance if my question seems basic but :-
What exactly is the difference between a Tween and an AnimationPlayer? In other words, what can a Tween do that an AnimationPlayer can’t, and vice versa?

Appreciate any assistance!

:bust_in_silhouette: Reply From: Zylann

Animation nodes such as AnimationPlayer and AnimatedSprite are more suited for fixed animations which are designed without code, using the editor. When you play them, they always play the same thing.

A Tween is an animation built from code, and is often constructed from one or multiple dynamic values, resulting into a procedural animation. See Tween — Godot Engine (3.1) documentation in English

And this for an example of situation where it can be useful: Control the game’s UI with code — Godot Engine (3.1) documentation in English

:bust_in_silhouette: Reply From: SIsilicon

First off let me just say that both the Tween and AnimationPlayer nodes are used for interpolating values and method call backs over time, i.e. animating.

  • Tweens are generally used for interpolating between values with variable duration, transition types etc. Best used on only a couple of values that change over the course of the game.
  • AnimationPlayers on the other hand are more generally used for handling multiple animations and has its own editor.

So honestly I would use Tween for when I just want to interpolate between two values over time, like position for example, and use AnimationPlayer for everything else.