Niagara Maintaining Constant Particle Count and Respawning Particles on Collision

Is there a way to keep the particle count of a Niagara system constant?

Additionally, is it possible to respawn a particle when it collides with a distance field?

Hi @X-perto, I can help you set this up! This will take a good amount of custom scratchpads, though.

So, we should start with the collision problem.

To start, you probably want to disable "Kill Particles When Lifetime

Now in the collision module, the module is writing several useable parameters to the particle. For this, we could use the particle’s velocity to determine if it has collided, but we also have the “Has Collided” parameter, so let’s use that.

You can add a “Kill Particles” module after the collision module, and add a new custom scratch input for the “Kill Particles” bool

Inside the custom scratch module, you’ll need to add the “HasCollided” as an input value. You can find this parameter here:

Then just connect it to your output

Now, your particles will be killed once they have collided with a surface.
As for replacing them, we’ll need to add some custom scratch pad logic to your spawning method. Start by turning your spawm rate into a bool. Set the “True Float” value to however many particles you wish to spawn normally.

Then, we’ll be using a custom scratch pad to determine the bool value.

image

We can get NumParticles the same way we did last time, and this will be our input value.

Now, for the logic:

You can set the 300 value to whatever value works for you. But now, if the system registers that there are less than 300 active particles, it will reactivate the spawn rate to spawn more until the 300 cap is reached again.

Let me know if you need any more help with this!

1 Like

I encountered an issue where I couldn’t find the HasCollided boolean inside the MapGet node in the Scratch Pad for the Kill Particles module.

That said, I was still able to use the boolean as an input value by selecting it from the dropdown menu. I’m not sure if this is a bug or if I might have overlooked something.

Aside from that, this works perfectly and achieves exactly what I was looking for. Thank you so much for your thorough and detailed response!