Set max_value = 1 and step = 0, then assign the ratio, or keep 0 to 100 and assign ratio * 100. In our Godot 4.7 test a TextureProgressBar with its defaults, max 100 and step 1, stored 0.37 as 0 and drew nothing. With max 1 and step still 1, 0.37 became 0 and 0.6 became 1, a full bar. With step 0 it kept 0.374 and filled 37.5%. For a ring, use Fill Mode Clockwise: it starts at the top, and radial_initial_angle 90 starts it at the right.
The code
Save it as ring_progress.gd. set_ratio() takes any Range node, sets it to 0 to 1 with no step and assigns the ratio. setup_ring() gives a TextureProgressBar a ring texture, a start angle (0 is the top, 90 the right), how many degrees a full bar covers, and the direction. For example: const RingProgress := preload("res://ring_progress.gd"), RingProgress.setup_ring($Cooldown, preload("res://addons/pd_hud124/textures/Ring/HUD_Ring_03.png")), then every frame RingProgress.set_ratio($Cooldown, time_left / cooldown). For a speed gauge with a gap at the bottom: RingProgress.setup_ring($Speed, tex, 225.0, 270.0).
extends RefCounted
## TextureProgressBar (and ProgressBar) helpers: show a 0-1 ratio without it being rounded away,
## and fill a ring or a gauge arc from the angle you want.
static func set_ratio(bar: Range, ratio: float) -> void:
# a Range rounds value to its step, and step is 1 by default
bar.min_value = 0.0
bar.max_value = 1.0
bar.step = 0.0
bar.value = clampf(ratio, 0.0, 1.0)
static func setup_ring(bar: TextureProgressBar, tex: Texture2D, start_deg := 0.0, sweep_deg := 360.0, clockwise := true) -> void:
bar.texture_progress = tex
bar.fill_mode = TextureProgressBar.FILL_CLOCKWISE if clockwise else TextureProgressBar.FILL_COUNTER_CLOCKWISE
bar.radial_initial_angle = start_deg # 0 = top, 90 = right, 180 = bottom
bar.radial_fill_degrees = sweep_deg
bar.radial_center_offset = Vector2.ZERO
What we measured
TextureProgressBars on a CanvasLayer: a white 200 by 20 bar filling left to right, and a white ring 256 px wide. We counted the lit pixels, and for rings which 45 degree slice they were in, clockwise from the top. Two runs gave the same numbers.
- Defaults: min 0, max 100, step 1, radial_initial_angle 0, radial_fill_degrees 360.
- The bar with its defaults, value set to 0.37: stored as 0.0, nothing drawn.
- max_value 1 with step still 1: 0.37 was stored as 0.0, empty. 0.6 was stored as 1.0, a full bar.
- Max 100 and the ratio times 100: 0.37 gave 37.0 and 37% of the bar. 0.374 also gave 37.0, because step 1 keeps whole numbers.
- set_ratio(): 0.37 stayed 0.37 and filled 37.0%. 0.374 stayed 0.374 and filled 37.5%.
- The ring, Fill Mode Clockwise, value 0.25: the quarter from the top to the right was full and nothing else, 25.0% of the ring. Counter Clockwise: the quarter from the top to the left. radial_initial_angle 90, clockwise: from the right down to the bottom. 0.37 clockwise: 37.1%.
- Start 225 degrees, 270 degrees of fill: full was 74.9% of the ring with nothing between 135 and 225 degrees, a gap at the bottom. Half filled from the bottom left up to the top. 0 drew nothing.
- HUD_Ring_03.png from 124 Sci-Fi HUD Elements, 1972 px, drawn at 400 px: clockwise at 0.5 it filled exactly the right half, from the top round to the bottom, and at 0.25 the top right quarter. Those were 52.6% and 31.4% of its lit pixels, because its details are not spread evenly around the ring.
Why it happens
TextureProgressBar is a Range node, like ProgressBar and the sliders. A Range snaps its value to the nearest multiple of step, and on a TextureProgressBar step starts at 1, so any value between 0 and 1 ends up as 0 or 1. That is easy to miss when a health or cooldown ratio is 0 to 1 and the bar's max is still 100 or 1. The radial fill modes measure angles in degrees from the top: radial_initial_angle is where the fill starts, turning clockwise, and radial_fill_degrees is how far a full bar reaches.
What to change
- A percentage label next to the bar: round it so it never shows 0% or 100% by mistake.
- A cooldown ring that keeps going while the game is paused: count the cooldown with the game's own time.
- A needle instead of a fill: keep the needle out of the gap at the bottom.
- A ring that also spins: center its pivot.
Rings and gauges to fill: 124 Sci-Fi HUD Elements has 24 rings and 10 gauges as white PNGs, ready for Godot 4. We used one of its rings in this test as the progress texture. It also comes inside Godot 4 Ready Kit.
Tested in Godot 4.7 with the Compatibility renderer.
Ready-made: 124 Sci-Fi HUD Elements has 24 rings and 10 gauges as white PNGs. We filled one of the rings as a TextureProgressBar in this test.
More how-tos: UI and HUD
- A screen fade that finishes while the game is paused or slowed
- 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
- 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