# Kill particle based on distance to other particles

**URL:** <https://forums.unrealengine.com/t/kill-particle-based-on-distance-to-other-particles/1710155>\
**Category:** FX\
**Tags:** unreal-engine\
**Created:** [February 24, 2024, 7:00pm UTC](https://forums.unrealengine.com/t/kill-particle-based-on-distance-to-other-particles/1710155 "2024-02-24T19:00:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oldzomb0t](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@oldzomb0t](https://forums.unrealengine.com/u/oldzomb0t)\
**Post date:** [February 24, 2024, 7:00pm UTC](https://forums.unrealengine.com/t/kill-particle-based-on-distance-to-other-particles/1710155/1 "2024-02-24T19:00:38Z")

</div>

Hi all,

New-ish to particles in unreal.

I want to create a module for kill particles that will kill/cull any particle that is a certain distance from its nearest particle.

I’m using a depth map to generate particle location but the if there is noise in the texture it generates rogue particles in the negative space where I don’t want them. so the best way would be to make a module and if any particle is x distance away from its closest neighbor then it kills it.

any tips would be very kind 🙂

---

<div class="post-metadata">

**Author:** ![jwatte](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jwatte/32/744941_2.png) [@jwatte](https://forums.unrealengine.com/u/jwatte)\
**Post date:** [February 24, 2024, 7:18pm UTC](https://forums.unrealengine.com/t/kill-particle-based-on-distance-to-other-particles/1710155/2 "2024-02-24T19:18:25Z")

</div>

For every particle to get data about where every other particle is, it would be very expensive to implement (it’s an n-squared operation.)  
It’s also quite hard to do on the GPU (it would need a very long loop per particle, and GPUs don’t like long loops.)  
I recommend you find some other way to do it. Can you read your depth map to figure out whether to kill a particle after the fact?

---

<div class="post-metadata">

**Author:** ![oldzomb0t](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@oldzomb0t](https://forums.unrealengine.com/u/oldzomb0t)\
**Post date:** [February 24, 2024, 7:24pm UTC](https://forums.unrealengine.com/t/kill-particle-based-on-distance-to-other-particles/1710155/3 "2024-02-24T19:24:29Z")

</div>

thanks for the reply, yea I was unsure if there was already a built in function that measured it. ill keep experimenting
