← Pixel Dreamer Studio

Stop flipbook particles from vanishing at the end of their life

When the sheet has fewer frames than grid cells, set the animation speed to frames divided by cells.

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.

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

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