09-03-2019, 03:48 PM
(This post was last modified: 09-03-2019, 04:51 PM by anonymous.
Edit Reason: situation progression
)
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.
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);
}
}
}
}