Godot Animation Tutorial: From Basics to Advanced

Master Godot's animation system. Covers AnimationPlayer, AnimatedSprite2D, Tweens, AnimationTree state machines, and procedural animation techniques.

Colorful abstract animation and motion

Animation in Godot is uniquely powerful. AnimationPlayer can animate ANY property on ANY node — not just transforms, but colors, shader parameters, audio volume, even function calls. Let's explore the full animation toolkit.

AnimatedSprite2D: Frame-by-Frame

Perfect for pixel art and sprite animations. Add frames to a SpriteFrames resource, set frame rate, and call play(). Each animation (idle, run, attack) is a named sequence.

gdscript
# Switch animations based on state
func update_animation():
    if velocity.length() > 10:
        $AnimatedSprite2D.play("run")
    else:
        $AnimatedSprite2D.play("idle")
    
    # Flip sprite based on direction
    if velocity.x != 0:
        $AnimatedSprite2D.flip_h = velocity.x < 0

AnimationPlayer: The Powerhouse

AnimationPlayer keyframes properties over time. Unlike other engines where you animate transforms, Godot lets you animate modulate (color), scale, visibility, material properties, audio, and even call functions at specific keyframes.

gdscript
# Play animation and await completion
$AnimationPlayer.play("attack")
await $AnimationPlayer.animation_finished
$AnimationPlayer.play("idle")

# Programmatic animation creation
var animation = Animation.new()
var track = animation.add_track(Animation.TYPE_VALUE)
animation.track_set_path(track, "Sprite2D:modulate")
animation.track_insert_key(track, 0.0, Color.WHITE)
animation.track_insert_key(track, 0.1, Color.RED)
animation.track_insert_key(track, 0.3, Color.WHITE)

Tweens: Code-Driven Animation

gdscript
# Smooth movement with easing
var tween = create_tween()
tween.set_ease(Tween.EASE_OUT)
tween.set_trans(Tween.TRANS_ELASTIC)
tween.tween_property($Sprite, "position", target_pos, 0.5)

# Chain animations
tween.tween_property($Sprite, "modulate:a", 0.0, 0.3)
tween.tween_callback(queue_free)  # Delete after fade

# Parallel animations
tween.set_parallel(true)
tween.tween_property($Sprite, "scale", Vector2(2, 2), 0.3)
tween.tween_property($Sprite, "rotation", PI, 0.3)

AnimationTree: State Machines

For complex character animation (idle → run → jump → fall → land), AnimationTree provides visual state machines with transitions, blend spaces, and conditions. Set parameters from code and the tree handles blending automatically.

👤
Godot Learning Team Helping developers transition to Godot with practical tutorials and comparisons.