+2 votes

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!

in Engine by (14 points)

2 Answers

+2 votes

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 https://docs.godotengine.org/en/3.1/classes/class_tween.html#description

And this for an example of situation where it can be useful: http://docs.godotengine.org/en/3.1/getting_started/step_by_step/ui_code_a_life_bar.html

by (27,966 points)
+1 vote

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.

by (3,881 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 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 webmaster@godotengine.org with your username.