A tween stops while get_tree().paused is true, unless its node keeps processing, and it runs slower when Engine.time_scale is below 1. In our Godot 4.7 test a 0.5 s fade on a black overlay was still at 0.0 after one real second with the game paused, from the overlay's own tween and from get_tree().create_tween() alike. Setting the overlay to Process Mode Always fixed the pause but not slow motion: at time_scale 0.1 it reached only 0.2. A tween with set_pause_mode(Tween.TWEEN_PAUSE_PROCESS) and set_ignore_time_scale(true) reached 1.0 in both cases.
The code
Save it as ui_fade.gd, load it with const UiFade := preload("res://ui_fade.gd") and fade with UiFade.to(overlay, 1.0, 0.5), where the overlay is any CanvasItem, such as a ColorRect over the screen. To wait for it: await UiFade.to(overlay, 0.0, 0.5).finished. Use it for pause menus, scene transitions and game over screens, and keep normal tweens for things that should stop with the game.
extends RefCounted
## Fades a screen overlay (a transition, a pause menu, a "Game Over" screen)
## so it keeps going while the game is paused or slowed down.
## A normal tween stops while get_tree().paused is true and slows down with
## Engine.time_scale, so a fade started at those moments freezes or crawls.
## UiFade.to(overlay, 1.0, 0.5) # fade in over 0.5 real seconds
## await UiFade.to(overlay, 0.0, 0.5).finished # fade out, then carry on
static func to(node: CanvasItem, alpha: float, seconds: float) -> Tween:
var t := node.create_tween()
t.set_pause_mode(Tween.TWEEN_PAUSE_PROCESS) # runs while the tree is paused
t.set_ignore_time_scale(true) # real seconds, whatever Engine.time_scale is
t.tween_property(node, "modulate:a", alpha, seconds)
return t
What we measured
A black ColorRect on a CanvasLayer, faded from 0 to 1 over 0.5 s, then read after one real second, timed with a timer that runs while paused and ignores time_scale. Two runs gave the same values.
- Game running, the overlay's own tween: 1.0.
- Game paused, the overlay's own tween: 0.0.
get_tree().create_tween(): 0.0. - Game paused, overlay set to Process Mode Always: 1.0. The script: 1.0.
- Engine.time_scale 0.1, not paused: the overlay's own tween 0.2, Process Mode Always 0.2, the script 1.0.
Why it happens
A tween made with create_tween() on a node follows that node: when the node would stop processing because the tree is paused, the tween stops too. A tween from get_tree().create_tween() stopped as well in our test. Process Mode Always keeps the node, and so its tweens, running, but tweens still count game time, and Engine.time_scale shrinks game time, which is what a hit stop or slow motion uses. TWEEN_PAUSE_PROCESS lets the tween run while paused whatever its node does, and set_ignore_time_scale(true) makes it count real seconds.
What to change
- A fade that blocks the buttons under it: mouse filter Ignore.
- Slow motion on hit: hit stop with time_scale. Cooldowns that should stop while paused: cooldowns and pause. A new fade that fights an old one: two tweens on one property.
Transitions with more style than a black fade: PD Ink Wash has 12 ink looks for 3D, 2D full-screen and sprite shaders, and 8 ink brush scene transitions that let clicks through to your buttons.
Tested in Godot 4.7 with the Compatibility renderer.
Ready-made: PD Ink Wash has 12 ink looks for 3D, 2D full-screen and sprite shaders, and 8 ink brush scene transitions that let clicks through to your buttons.
More how-tos for PD Ink Wash: Full-screen post-process shader in 3D
More how-tos: UI and HUD
- A hand of cards that always fits, without spreading out when it is small
- Edge markers that stay on the rim and point the true way
- A wrapped Label that is as wide as its text, up to a limit
- Big numbers with thousands separators, minus signs and all
- Show a 0 to 1 ratio on a progress bar, and fill a ring or gauge from the angle you want
- Blink or fade a tinted HUD element without losing its color
- Spin a HUD ring, radar or icon in place instead of around its corner
- Make buttons clickable again under a full-screen fade, transition or post-process ColorRect
- 9-slice window: corners that do not stretch
- Visual novel background: fill the screen, crossfade scenes
- Coins that fly to the HUD counter
- Floating damage numbers in 2D
- An icon over a 3D character's head, without the ghost behind the camera
- Drag a box to select 3D units, in any direction
- Radar blips that turn with the player
- Pick the radial menu slot the mouse is pointing at
- Show a percent that never says 0% or 100% too early
- Type dialogue at the same letters per second on every line and every frame rate
- Place brush dots at the same spacing however fast the mouse moves
- Move a speedometer or gauge needle smoothly without cutting through the bottom
- A countdown that never shows 0 while time is left
- A coin counter that rolls up and lands on the real total