godot-animation
Original:🇺🇸 English
Translated
Animate in Godot 4.x three ways: AnimationPlayer for keyframed clips (incl. call and signal tracks), AnimationTree with state machines and blend spaces for character animation, and Tween for short procedural/UI tweens via create_tween(). Use when working with AnimationPlayer/AnimationTree nodes in a .tscn, blending character states, sprite-sheet animation, or code-driven Tweens.
12installs
Added on
NPX Install
npx skill4agent add gamedev-skills/awesome-gamedev-agent-skills godot-animationTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Godot Animation (4.x)
Choose and drive the right animation tool: (clips),
(blending/state machines), or (short procedural moves). Targets Godot 4.3+.
AnimationPlayerAnimationTreeTweenWhen to use
- Use when playing keyframed animations, blending walk/run/idle states, animating a sprite sheet, or tweening UI/objects in code.
When not to use: the movement logic that decides which state to play →
; UI layout (vs. UI tweening) → ; shader-driven
effects → .
godot-2d-movementgodot-ui-controlgodot-shadersCore workflow
- Pick the tool:
- — author keyframed clips (transforms, properties, method calls, audio, even other animations). The source of truth for clip data.
AnimationPlayer - — blend and transition between those clips at runtime with a state machine and/or blend spaces. Needs an
AnimationTreeto pull clips from.AnimationPlayer - — fire-and-forget procedural interpolation in code (
Tween); ideal for UI pops, fades, and one-off moves.create_tween()
- For 2D sprite sheets: use +
AnimatedSprite2D, or keyframe theSpriteFramesproperty in anframe.AnimationPlayer - For characters: build clips in , then add an
AnimationPlayer(AnimationTree), set itsactive = true, and design ananim_playerorAnimationNodeStateMachineas the tree root.AnimationNodeBlendSpace2D - Drive transitions from code via the playback object () or by setting blend parameters.
travel - React to clip events with the signal and call/method tracks.
animation_finished
Patterns
1. AnimationPlayer: play a clip and await it
gdscript
@onready var anim: AnimationPlayer = $AnimationPlayer
func attack() -> void:
anim.play("attack")
await anim.animation_finished # resume after the clip ends
anim.play("idle")2. AnimationTree state machine: travel between states
gdscript
@onready var tree: AnimationTree = $AnimationTree
func _ready() -> void:
tree.active = true # the tree drives animation; AnimationPlayer is the source
func set_state(state: StringName) -> void:
# The playback object controls an AnimationNodeStateMachine root.
var sm: AnimationNodeStateMachinePlayback = tree.get("parameters/playback")
sm.travel(state) # transitions using the graph's connections
func _physics_process(_d: float) -> void:
set_state(&"run" if velocity.length() > 5.0 else &"idle")3. Blend space: blend run direction by a 2D parameter
gdscript
# Root is an AnimationNodeBlendSpace2D named "Move" with idle/run points placed in it.
func update_locomotion(input_dir: Vector2) -> void:
# Parameter path = "parameters/<node name>/blend_position".
tree.set("parameters/Move/blend_position", input_dir)4. Tween: fade and scale a UI element (code-driven)
gdscript
func pop_in(node: Control) -> void:
node.scale = Vector2.ZERO
node.modulate.a = 0.0
var tw := create_tween() # bound to this node's tree
tw.set_parallel(true) # run the two tweens together
tw.tween_property(node, "scale", Vector2.ONE, 0.2) \
.set_trans(Tween.TRANS_BACK).set_ease(Tween.EASE_OUT)
tw.tween_property(node, "modulate:a", 1.0, 0.2) # sub-property via ":"Pitfalls
- left false → nothing animates and
AnimationTree.activeappears to do nothing. Settravel()and assign theactive = truepath.anim_player - Wrong parameter path. Blend/condition paths are and must match the node names in the tree exactly (e.g.
"parameters/<NodeName>/...","parameters/playback"). A typo silently no-ops."parameters/Move/blend_position" - AnimationPlayer and AnimationTree fighting. When an is active, don't also call
AnimationTreefor the same tracks — let the tree own playback.AnimationPlayer.play() - 3.x Tween node is gone. There is no node to add in 4.x; create tweens in code with
Tween(which returns acreate_tween()). They auto-start and free themselves.Tween - Reusing a finished tween. A tween is one-shot; call again for a new animation. Use
create_tween()for repetition.set_loops() - /
yieldis gone. Useyield(anim, "...").await anim.animation_finished - Sub-property tweens use a colon: ,
"modulate:a". Tweening the whole property instead overwrites siblings."position:x"
References
- For state machine transitions/conditions, root motion, one-shot/blend nodes, method &
call tracks, /
SpriteFrames, and Tween easing/chaining/callbacks, readAnimatedSprite2D.references/animation-tree-and-tween.md
Related skills
- — supplies the velocity/state that selects animations.
godot-2d-movement - — UI that Tweens animate.
godot-ui-control - — 3D character scenes driven by AnimationTree.
godot-3d-essentials - — state machines that mirror animation states.
game-ai