In Niagara, “find neighbours” depends on whether you’re simming on CPU or GPU. GPU has proper spatial acceleration (fast). CPU is usually done via events or custom data structures (slower).
Here are the main ways people do it in UE 5.5:
This is the go-to for boids/flocking, separation, swarm, local density, etc.
It bins particles into a 3D grid (a spatial hash), then you query the grid cell you’re in (and optionally adjacent cells) to get nearby particle indices.
Emitter/System (GPUCompute Sim):
- Add a Neighbor Grid 3D data interface (usually in System or Emitter parameters).
- Clear / Reset grid (once per frame)
- Usually a module like Neighbor Grid 3D Clear in Emitter Update.
- Write particles into the grid
- Module often called something like Neighbor Grid 3D Set / Build / Write in Particle Update (or a dedicated stage).
- Query neighbours
- Use a module/script like Neighbor Grid 3D Query / Find Neighbors to iterate neighbor indices and accumulate forces (separation/alignment/cohesion).
- Cell Size: sets neighbor search radius baseline (smaller = more accurate, more cost).
- World Bounds / Grid Extents: defines the volume the grid covers (outside = no neighbors).
- Max Neighbors Per Particle: clamps loop cost.
Rule of thumb: set Cell Size ≈ your desired neighbour radius (or a bit smaller), then check 1-cell radius or 2-cell radius around.
If you just need “neighbors” for, say, a few hundred particles, you can brute-force-ish:
- Read positions from another emitter using Particle Attribute Reader
- Loop over a limited number of particles
- Compute distances and keep the closest N
This scales badly (O(N²)) so it’s not for big swarms.
CPU Niagara doesn’t have the same fast neighbor grid workflow by default.
What you can do:
- Use Collision Events (e.g., “when particles collide, send an event”)
- Or create custom “proximity events” by doing a simplified distance check (only viable for small counts)
- Or handle neighbor finding externally (Blueprint/C++) and feed results back (heavy but flexible)
If what you mean by “neighbors” is more like:
- local density
- “how crowded is it here?”
- flow field influence
Then you can rasterize particles into a Grid3D (or Grid2D), blur/smooth, then sample the field—often cheaper than explicit neighbor loops.
- Flocking / separation / swarm → Neighbor Grid 3D (GPU)
- Small particle count, custom pairing → Attribute Reader
- Crowding/density forces → Grid field
- CPU sim → events or external logic
- Is your emitter GPUCompute Sim or CPUSim?
- Do you want neighbors within a radius (e.g., 50 units) or “closest N” (e.g., closest 8)?