Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Overwriting Particles As Capacity Reached
#1
Hi there,

I am trying to implement a use of Obi Fluid where bleeding is simulated and remains on the ground.  I would like to use an emitter that continually emits particles even once the particle limit (capacity) for the blueprint is reached.  I only want particles to be destroyed/recycled after the maximum amount of particles have been spawned so that there is a continuous emission.  Once the emission stops, I would like the particles that have already been spawned and are sitting on the floor to remain there indefinitely or as long as possible.

Basically I don't want the particles to die until particle capacity is reached and then I only want them to die at a rate that is needed to continue emission.

From reading through these forums, I think this would be possible through emitter.KillParticle and setting lifespan to infinity.  Is this the correct/most performance efficient way to implement this?  I'm imagining that I would just write a script that checks if the number of particles is nearing max capacity and then starts to kill the oldest particles at the same rate they are being emitted.  Can this just go in any old Update() function or is there a better place to put it?

Thank you
Reply
#2
(18-12-2022, 02:04 AM)mapleleaf4evr Wrote: Basically I don't want the particles to die until particle capacity is reached and then I only want them to die at a rate that is needed to continue emission.

Hi!

What you're describing is basically a ring buffer, am I correct?

(18-12-2022, 02:04 AM)mapleleaf4evr Wrote: From reading through these forums, I think this would be possible through emitter.KillParticle and setting lifespan to infinity.  Is this the correct/most performance efficient way to implement this?

Yes.

(18-12-2022, 02:04 AM)mapleleaf4evr Wrote:   I'm imagining that I would just write a script that checks if the number of particles is nearing max capacity and then starts to kill the oldest particles at the same rate they are being emitted.  Can this just go in any old Update() function or is there a better place to put it?

Physics related stuff should generally be updated in FixedUpdate(). Obi allows you to change where solvers are updated though, trough the use of ObiUpdater components. To implement this properly regardless of where the solver is updated, you should do this whenever particles are to be emitted: during the solver's OnBeginStep event. See: http://obi.virtualmethodstudio.com/manua...olver.html

kind regards,
Reply