How to remove a particle from a particle system

I’m using particles to create tracers from a gun. Every Update(), I walk through the .particles array and raycast from each particle to check for collisions.

My problem is that I can’t figure out how to remove a particle from the emitter upon collision. I think it may only be a matter of making a copy of the particle array, removing the required index, and then reassigning the array back to the emitter… but my array knowledge is still poor enough that I can’t make this happen.

Does anyone know how to do this?

Thanks!

You can assign the particles to a JS array, use RemoveAt to drop the element you don’t want and then create a built-in array from the JS array and assign it back:-

var tempParts = Array(particleEmitter.particles);
tempParts.RemoveAt(doomedIndex);
particleEmitter.particles = tempParts.ToBuiltIn(Particle);