How to get GPUParticles2D to use a random sprite for each particle

Godot Version

v4.6.stable.official [89cea1439]

Question

I have a 2D game, and am trying to make a particle effect that looks like dust and debris when the player is drilling through rock. I’ve got it emitting particles, but I need help getting it to randomly pick each particle’s sprite from a sprite sheet.

I have a GPUParticles2D object attached to the player. The texture is set to a sprite sheet (png) with 32 different dust/debris sprites (8 columns x 4 rows). The Material is a CanvasItemMaterial with Particles Animation enabled, and H Frames = 8 and V Frames = 4.

Then in the ParticleProcessMaterial, I adjust all the various emission parameters to get the look I’m going for. This all works, but it always uses the last sprite on the sprite sheet. Clearly it is mostly working, since it is slicing up the sprite sheet to emit just one cell of it. I want each particle to have a random sprite from the sheet (not animated).

From googling around, it sounds like there should be an Animation section in the ParticleProcessMaterial where I need to set Offset and Offset Random to 1. Unfortunately, I can’t make the Animation section appear no matter what I do. I’ve tried tweaking just about every setting, and deleting and recreating the node and resources, but no Animation section appears. Note that there IS an Animation subsection under the Display section, but it doesn’t have an Offset Random parameter.

I also tried to set these values programmatically, but I could only find ParticleProcessMaterial.anim_offset_min and _max. I couldn’t find anything like anim_offset_random

What am I missing?

Thanks!

(Sorry if this isn’t the best place to post this question - it isn’t clear if Particle questions belong to the Shaders or Animation category…)

In process material under Display/Animation set speed range to 0-0 and offset range to 0-1. Assign a new canvas item material to node’s material property and in material’s properties enable particle animation and set the h/v frames to match your sheet.

1 Like

Thanks - that got it to work!

I was so close … just needed to set the minimum offset to 0, which now that I know what was wrong makes sense. Having min and max both set to 1 stuck it on the last frame, which is what I was seeing.

What really tripped me up was all the explanations I found on google/ai that said a new top level section called “Animation” would appear in the ParticleProcessMaterial with a parameter called Offset Random. I guess that was far a previous version of Godot? Regardless, I’m unstuck now.

Thanks for the help!