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.
Scripting it
Section titled “Scripting it”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.
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()- Keep the handle.
Tweens.play()returns it at once, andstart()keeps it inmovement. - Await the end.
await movement.endresumes once playback ends, with the reason:COMPLETED,CANCELLED, orOWNER_EXITEDwhen the scene closes first. - Control it.
pause()holds the current value untilresume().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).
React to the end
Section titled “React to the end”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.
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.
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.
Would you like to know more?
Section titled “Would you like to know more?”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.