GDScriptBeta
Cancellation
Awaiting a tween resumes however it ends, cancelled or not. Check the reason when the next step needs the motion to have arrived.
Examples use the global Tweens class in a node script, with targets inside the scene tree.
Cancel playback
Section titled “Cancel playback”movement.cancel() stops a tween where it is and resumes everything awaiting it. Groups and Chains cancel the same way, and Tweens.cancel_tweens(sprite, true) cancels everything a node and its descendants own.
Continue only on success
Section titled “Continue only on success”var tween := sprite.create_tween()tween.tween_property(sprite, "position", Vector2(400, 180), 0.6)await tween.finished # Not emitted if killed.
sprite.create_tween().tween_property(sprite, "modulate:a", 0.0, 0.3)var movement := Tweens.play(sprite, Tweens.position_2d([400, 180], 0.6))if await movement.end != Tweens.Reason.COMPLETED: return
Tweens.play(sprite, Tweens.modulate_alpha(0.0, 0.3))Godot doesn’t emit finished for a killed tween, so code awaiting it never continues. end always resumes with a reason: here, the fade runs only after the sprite arrives, and never on a sprite freed along the way.
Why it ended
Section titled “Why it ended”| Reason | Meaning |
|---|---|
COMPLETED |
Reached the natural end |
CANCELLED |
Cancelled through a handle or cancel_tweens() |
TARGET_FREED |
Target was queued for deletion, or found freed |
OWNER_EXITED |
Owner left the tree, or a separate owner was queued for deletion |
RUNNER_DISPOSED |
Tree or scheduler shut down |
FAILED |
Start or playback hit a problem; read error |
WAIT_CANCELLED |
Only the wait was cancelled |
Cancel a wait, not the tween
Section titled “Cancel a wait, not the tween”await movement.wait(cancellation) returns WAIT_CANCELLED once the TweensGdCancellation is cancelled. Playback, other waiters, and the handle’s own reason are unaffected. Groups and Chains have the same method.
tweens.gd is made with math & ferrets, copyright © 2026 its contributors.
Godot logo by Andrea Calabró, licensed under CC BY 4.0.
"Easy, the Ferret" illustrations drawn by foxy_maria.
tweens.gd is released under the MIT License.
Godot is licensed under the MIT License.
tweens.gd is not affiliated with or endorsed by the Godot Foundation.