Particle burst with exact amount of particles

Hello dear forum,

I need to emit an exact amount of particles from a SCNParticleSystem in a burst (this is for an UI effect). This worked for me perfectly in the scene editor by setting the birthrate to the amount and emission duration to 0.

Sadly when I either load such a particle system from a scene or creating it by code, the emitted particles are sometimes one less, or one more.

The first time I run it in the simulator, it seems to work fine but then amount of particles varies as described.

video: https://youtube.com/shorts/MRzqWBy2ypA?feature=share

Does anybody know how to make this predictable?

Thanks so much in advance,

Seb

Answered by DTS Engineer in 807456022

"setting the birthrate to the amount and emission duration to 0." is intended for a static effect i.e. "A duration of 0.0 specifies that all particles (the value of the birthRate property) spawn instantaneously. Use this duration to create randomized static effects in your scene." See emissionDuration.

SCNParticleSystem guarantees that "The total count of particles on screen at any time is the product of the system’s birthRate and particleLifeSpan properties." which explains the varying number of particles at any given time in a non-static scene.

It seems that you would need to adjust particleLifeSpan to achieve the effect you seek.

"setting the birthrate to the amount and emission duration to 0." is intended for a static effect i.e. "A duration of 0.0 specifies that all particles (the value of the birthRate property) spawn instantaneously. Use this duration to create randomized static effects in your scene." See emissionDuration.

SCNParticleSystem guarantees that "The total count of particles on screen at any time is the product of the system’s birthRate and particleLifeSpan properties." which explains the varying number of particles at any given time in a non-static scene.

It seems that you would need to adjust particleLifeSpan to achieve the effect you seek.

Particle burst with exact amount of particles
 
 
Q