Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to destroy particle from it's position
#1
Hi.

I need particles to be killed once they are below a given position.y
In my situation, the particles should live as long as they don't fall below some position. Once enough are killed, new ones would be emitted.

Here's my code for now but something is not right. It finds the particle pos but the kill part does not seem to work because my active particle number (in the emitter inspector)  stays the same when running. If possible, I would like also something less demanding than having to regularly loop through the array to do the pos check. 
Code:
  IEnumerator PurgeParticlesTooLow()
   {
       while(true)
       {
           yield return new WaitForSeconds(5);

           Vector4 v4;
           for (int i = 0; i < obiSolver.positions.Length; ++i)
           {
               v4 = obiSolver.positions[i];
               print("pos particle: " + v4);
               if (v4.y <= GlobalVars.cstBallBreakPointY)
               {
                   obiEmitter.life[obiSolver.particleToActor[i].indexInActor] = 0;
                   print("killed particle at pos: " + v4);
               }
           }

       }
   }
Reply


Messages In This Thread
How to destroy particle from it's position - by anonymous - 09-03-2019, 03:48 PM