Skip to content
tweens.gd

GDScriptBeta

Loops and delays

Ping-pong sends a motion back to where it started; repeats play it again. Together they make idle motion that runs on its own.

Examples use the global Tweens class in a node script, with targets inside the scene tree.

Godot's Tween
var tween := sprite.create_tween().set_loops()
tween.set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)
tween.tween_property(sprite, "scale", Vector2(1.1, 1.1), 0.8)
tween.tween_property(sprite, "scale", Vector2.ONE, 0.8)
tweens.gd
var pulse := Tweens.scale_2d([1.1, 1.1], 0.8, InOut.SINE) \
.with_ping_pong().with_repeats(Tweens.INFINITE)
Tweens.play(sprite, pulse)

The sprite grows for 0.8 seconds, shrinks for 0.8 seconds, and repeats until cancelled or removed from the tree. Ping-pong returns to the scale the sprite had at the start, so the return leg needs no value of its own.

Set Effect
with_repeats(2) Three cycles: the first plus two repeats
with_ping_pong() Each cycle goes there and back; duration applies to each leg
with_ping_pong_interval() Pause at the far end before the return leg
with_repeat_interval() Pause between cycles

Try it: raise repeats, then drag the timeline to see where each interval falls.

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.
DelayProgress 0.00Cycle 1 / 2t = 0.00 s

DelayForward legPing-pong intervalBackward legRepeat interval

fill chooses what a delayed tween shows before it starts and after it ends. For an entrance, Tweens.Fill.BOTH applies the from value during the delay and keeps the final value:

var fade_in := Tweens.modulate_alpha()
fade_in.from_value = 0.0
fade_in.duration = 0.3
fade_in.delay = 0.5
fade_in.fill = Tweens.Fill.BOTH
Tweens.play(label, fade_in)

The label stays hidden for half a second, then fades in to its own alpha. The default fill, RETAIN_FINAL_VALUE, would leave it visible during the delay, so it would blink out before fading in.

Each row below plays one delayed tween with a different fill mode:

RETAIN_FINAL_VALUE
APPLY_FROM_DURING_DELAY
BOTH
NONE

From at leftcaptured initial value (dashed)To at right

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.