Set the ParticleProcessMaterial's anim_speed_min and anim_speed_max to the number of frames on the sheet divided by the number of grid cells, for example 30 / 36 = 0.833 for 30 frames in a 6 x 6 grid, with Loop off on the CanvasItemMaterial. A speed of 1 plays every cell once per lifetime, empty ones included. In our Godot 4.7 test the particle was missing in 17% of the screen frames with 1, and in 3% with 0.833.
The code
Put it on the GPUParticles2D and fill in h_frames, v_frames and frame_count. It turns on Particles Animation in the CanvasItemMaterial with the grid size and Loop off, and sets the speed so the last drawn frame lands at the end of the particle's life.
extends GPUParticles2D
## Plays only the frames that are drawn on a sprite sheet whose grid ends with empty cells,
## for example 30 frames in a 6 x 6 grid, so particles do not blink out before they die.
@export var h_frames := 6
@export var v_frames := 6
@export var frame_count := 30 # frames actually drawn on the sheet
func _ready() -> void:
var cm := material as CanvasItemMaterial
if cm == null:
cm = CanvasItemMaterial.new()
material = cm
cm.particles_animation = true
cm.particles_anim_h_frames = h_frames
cm.particles_anim_v_frames = v_frames
cm.particles_anim_loop = false
var part := float(frame_count) / float(h_frames * v_frames) # 1.0 = every cell once per lifetime
var pm := process_material as ParticleProcessMaterial
pm.anim_speed_min = part
pm.anim_speed_max = part
What we measured
A 384 x 384 sheet, 6 x 6 cells of 64 px, with a white disc in the first 30 cells and the last 6 left empty. One GPUParticles2D particle, lifetime 1 second, not moving. For 3 seconds we checked every screen frame for any lit pixel. Two runs gave the same shares.
anim_speed1, all 36 cells per lifetime: the particle was missing in 17% of the frames (29 of 166, then 29 of 171), one sixth, the 6 empty cells.- The script, speed 0.833: missing in 3% (5 of 170, then 6 of 179). We put that down to the moment between one particle and the next, since amount was 1.
- A new ParticleProcessMaterial starts with
anim_speedat 0.000, so the animation stays on the first frame until you raise it.
Why it happens
Godot does not know which cells are drawn. With h and v frames set to 6 it treats the sheet as 36 frames, and a speed of 1 spreads all 36 over the lifetime, so the particle spends its last sixth on empty cells and looks like it disappears early. A grid picked to make a square sheet, like 6 x 6 for 30 frames, leaves cells empty at the end.
Other sheet sizes
- 20 frames in a 5 x 5 grid: 20 / 25 = 0.8.
- 48 frames in an 8 x 8 grid: 48 / 64 = 0.75.
- A full grid with no empty cells: 1.
Make your own sheets: PD Flipbook Forge builds VFX flipbook sprite sheets in the browser from 14 effect recipes, with a pixel art mode and a Godot 4 export.
Tested in Godot 4.7 with the Compatibility renderer.
Ready-made: PD Flipbook Forge builds VFX flipbook sprite sheets in the browser, with a pixel art mode and a Godot 4 export.
More how-tos for PD Flipbook Forge: Sprite sheet frames without lines from the next cell
More how-tos: When particles do not show up
- Big particle effects that stay on screen
- GPUParticles3D not showing in Godot 4
- GPUParticles2D not showing in Godot 4
- GPUParticles2D collision: fall through or vanish
- Particles look black or dark
- Particles only fall down or fly sideways
- Particles not working in a web export
- Particles fall through the floor
- Particles on terrain and uneven ground
- Flipbook animation on GPUParticles3D
- GPUParticles2D sprite sheet not animating
- Pixel art particles look blurry
- Particle trails in the Compatibility renderer
- GPUParticles2D trails not working
- Particle color over lifetime not working
- Particle texture shows a square box
- Custom particle shader ignores the color ramp
- Particle scale curve not working
- Additive particles invisible on a white background
- Transparent PNGs without a dark outline
- Scale a 3D particle effect evenly
- Particles the same size on screen at any distance