How to get spriteRandomStartCell = true to work?

I am dealing with internal code, so I cannot construct a scene.

I have a sprite sheet of 4 sprites. I’m able to get a particle emitter to cycle through the 4 sprites on the sprite sheet just fine.

However, I do not want them to be animated. For now, I set it spriteCellChangeSpeed to 0.01, because I could find no further information making sprites not animate.

The sprite cell ID’s work as I would expect. If I set the start/end cell ID’s to be the same, I can get the emitter to emit only that sprite. However, I wish for the sprites emitted to be a random selection between ID 0 and ID 3. If I set startSpriteCellID to 0 and endSpriteCellID to 3, the emitter only picks ID 0. I cannot get it to randomly pick.

How do I get it to randomly pick, since spriteRandomStartCell = true isn’t doing as I thought it would do?

Since I can’t show code, are there any example scenes I could look at which use random sprite particle emitters?

particleSystem.spriteCellChangeSpeed = 0;
particleSystem.spriteRandomStartCell = true;

should achieve that :thinking:

1 Like

This works as long as you do not want them animated. Since the change speed is at 0 it won’t animate.
Admit you would want to cycle through a spritesheet of say 24 frames and want to randomly start between frame n0 and frame n4 (say 0 min and 4 max) and run the entire animation of 24 frames from there at whatever animation speed.
In this case, I believe the only way would be to change the startSpriteCellID on runtime.
Something like this, may be:

Unless I missed something, It’s kind of sad that you cannot set a range for start and end cells independant from the length of the animation (and speed). May be a future possible improvement?

@mawa

:sweat_smile:

In your scenario; (however, it would be a random start out of all sprites/cells)

particleSystem.spriteCellChangeSpeed = 1;
particleSystem.spriteRandomStartCell = true;
particleSystem.spriteCellLoop = true;

Thanks for this! I did not realize that spriteCellChangeSpeed = 0 was an option. For some reason, the first time I tried it, I got strange results. It works for me now, though!