Using Sprites in Particle System

Hi all, this might be a noobish question but…here goes. :slight_smile:

I have a spritesheet with a few rows of sprites, and I want to pass different sprites into the particle system at various times, based on the user clicking particular buttons. I don’t actually want to animate the sprites in a running sequence, I just want to pass different sprites in to the particle system at different times. So one sprite might be used in the particle system during a certain interval, then much later a different sprite might be used in the same particle system.

I’ve been doing this by following the documentation for using sprites with the particle system here (Animating Particles | Babylon.js Documentation), but I see this documentation assumes that you will be animating through different sprites in a rapid sequence, something which I’m not doing.

In my code, because I just want to use the same sprite while the particle system is running, I end up just doing something like:

particleSystem.startSpriteCellID = 0;
particleSystem.endSpriteCellID = 0;

This “works”, in that I get the behavior I expect. But is it possible to use sprites/spritesheet with the particle system WITHOUT it assuming that I’m trying to animate through certain sprites? I wonder if this animation situation doing something behind the scenes which is a bit overkill given my use case.

Thanks for any help,

Gabe

Hey @gabrieljbaker. Pretty new here myself but would like to suggest a bit different approach. I have read that with SPS you can define materials particle system will be using and assign them to individual particles during update step. I believe different materials can be fed from the same sprite sheet rendering relevant part of the image based on configured uvs.

Take a look at example in SPS material docs.

One of the examples updates particle materials.

Hope it helps a bit.

1 Like

This is an intriguing idea @MarkBevels , thanks for this suggestion! Isn’t the SPS really designed for using meshes inside of a particle system, though? Would this also work with just regular flat texture sprites as particles? I only see ways to define meshes inside the SPS.

The sps can.for sure let me find a good PG.

2 Likes