Manually destroying particles in Niagara

Hi!

I’m working on an enemy system with Niagara with many thousand enemies at the same time. Everything is working fine so far, but I’m still trying to find a better solution for destroying my enemies.

What I’m trying to achieve:

  • Enemies live infinitely
  • Enemies are killed manually when they receive enough damage

Current approach:

  • Use ParticlesLifetime for destroying. Simply just set it to zero

Problem:

  • In order to use this, I have to check “Kill particles when lifetime ends” in ParticleState. However this means I need to assign a lifetime on spawn. Meaning enemies will just disappear when the lifetime has ended.

I tried to just set lifetime back to a higher number with <= check and if/select in ParticleUpdate. However this gets just ignored. I can’t seem to extend the lifetime, only reduce it.
I could just assign a very high value to lifetime on spawn but maybe there is another way? Any suggestions how to do this smoother?

Thanks!

1 Like

So, each enemy is a particle of the same emitter? How are you handling damage to individual enemies?

1 Like

Hey,

I have several emitters, each with a different enemy type.
To update health of a particular enemy you can send a vector with ParticleID and Float for Health to Niagara. Then check with a for each loop (Map for) for ParticleID and set individual health of the particle.
Map for took me a little to get working properly.

1 Like