Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Changing NumParticles at runtime?
#3
(30-04-2018, 08:44 AM)josemendez Wrote: Hi,

ObiEmitter already works by preallocating a fixed amount of particles (NumParticles) and activating particles as they need to be emitted. This ensures zero garbage generation and no allocation overhead.

The ObiEmitter class has two methods: EmitParticle() and KillParticle() specifically designed to allow what you want to do. Note however that when emitting particles manually you need to be extra careful about their spacing, to avoid sudden pressure spikes. Each particle represents a small amount of mass, so if too many particles are spawned at once in the same place, the density (and the pressure) will skyrocket resulting in a sudden burst. That's why "speed" is used to control emission, as it controls both the emission speed and the amount of particles to ensure constant density.

I also couldn't change the number of particles at runtime.

emitter.NumParticles = 40000;
StartCoroutine(emitter.Initialize);

"Initialize" didn't work bcs it's inaccessible due to its protection level. I have changed it from protected to "public" but it also didn't do the trick. Please, help me, thx.
Reply


Messages In This Thread
Changing NumParticles at runtime? - by tooomg - 28-04-2018, 02:05 AM
RE: Changing NumParticles at runtime? - by mimarilker - 05-07-2018, 08:49 PM