Skip to content
tweens.gd

GDScriptBeta

Await Completion

Every start returns a handle. Await it to continue once the tween ends, or use it to pause and cancel the tween on the way.

Animations are paused

Reduce Motion is on, or Animation Effects are off.
(e.g. in your accessibility settings)

Applies to this demo until you reload.

The remote’s buttons call this script’s functions. To build your own, attach it to a scene’s root Node2D, pick a Sprite2D for Sprite in the Inspector, and connect each button’s pressed signal to its function.

playback_remote.gd
extends Node2D
## The remote's buttons call these functions; ended reports how the movement ended.
signal ended(reason: int)
@export var sprite: Sprite2D
@export var to := Vector2(1024, 128)
var movement: TweensGdHandle
func start() -> void:
movement = Tweens.play(sprite, Tweens.position_2d(to, 2.4, InOut.SMOOTHER_STEP))
ended.emit(await movement.end)
func pause() -> void:
movement.pause()
func resume() -> void:
movement.resume()
func cancel() -> void:
movement.cancel()
  1. Keep the handle. Tweens.play() returns it at once, and start() keeps it in movement.
  2. Await the end. await movement.end resumes once playback ends, with the reason: COMPLETED, CANCELLED, or OWNER_EXITED when the scene closes first.
  3. Control it. pause() holds the current value until resume(). cancel() stops for good and keeps the latest value.

To stop every tween a node owns without keeping their handles, call Tweens.cancel_tweens(sprite).

Await the handle to continue in the same function. end resumes however playback ended, so check the reason when the next step needs an arrival.

Await
var arrive := Tweens.position_2d([400, 180], 0.6, Out.CUBIC)
var movement := Tweens.play(sprite, arrive)
if await movement.end == Tweens.Reason.COMPLETED:
print("Arrived")

A callback on the definition suits a small synchronous reaction. on_end runs only on natural completion.

Callback
var arrive := Tweens.position_2d([400, 180], 0.6, Out.CUBIC) \
.with_on_end(func(_handle): print("Arrived"))
Tweens.play(sprite, arrive)

on_finally also runs when playback stops early or fails; callback order shows the whole lifecycle.

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.