Niagara Swarm
GPU based BOID system
Had the opportunity to create a gameplay-driven GPU SWARM BOID system featuring dynamic spawning, custom flocking behaviors, and runtime formation control for an upcoming project.
It was designed to scale to large numbers of agents while remaining performant, it supports per-unit interaction, Niagara Grid based destruction and seamless synchronization between visuals and gameplay systems.
The behavior was abstracted in different Niagara simulation stages for easy of iteration and implementation.
Overview
The core idea behind the system was to simulate a flock-like behavior where each particle reacts to nearby agents while also following a shared target or “leader.” This allowed the swarm to feel alive and responsive instead of moving as a rigid group. Each boid evaluates simple behavioral rules such as separation, alignment, cohesion, and target attraction, producing emergent motion that feels natural while remaining lightweight enough to run with many agents on screen.
The system was built with flexibility in mind. Rather than relying on hand-authored animation, the swarm movement is generated procedurally inside Niagara, making it possible to quickly adjust the density, speed, noise, responsiveness, and overall behavior of the group. This gave me a strong level of control over the final look while keeping the setup reusable across different gameplay and VFX scenarios.
A key part of the setup was the leader-following behavior. The swarm can be driven by a master position, allowing the boids to chase, orbit, or gather around a specific point in the world. This made it possible to use the system for effects such as “monster” swarms, enemy clusters, energy particles, drones, or abstract gameplay indicators.
Early RnD, system was inspired by epic boids showcase
Niagara Setup / Techinal Implementation
The swarm was implemented as a GPU Niagara particle system, with each particle representing an individual boid. The simulation runs directly inside Niagara, allowing a large number of agents to update every frame without requiring individual Actor or Component instances.
The core behavior is calculated in the particle update stage. Each boid samples nearby particles and applies a combination of classic flocking forces:
Separation keeps particles from collapsing into each other.
Alignment encourages nearby boids to move in a similar direction.
Cohesion pulls each boid toward the local center of nearby neighbors.
Leader attraction drives the entire swarm toward a master target position controlled externally.
The leader target is exposed to Niagara as a user parameter, so it can be updated from Blueprint or gameplay code. This gives the system a simple control point while still allowing the particles to generate their own local motion procedurally.
BOID Modules
A “Module” system was implemented into the system in order to control the principles separation, alignment, cohesion, and leader attraction.
The Separation module is responsible for preventing the boids from collapsing into each other. Each particle checks nearby neighbors within a defined radius and calculates a repulsion force away from them.
The Alignment module makes each boid try to match the movement direction of nearby boids. It samples neighbors inside a defined radius, averages their velocity, and gently steers the current particle toward that shared direction.
The Cohesion module keeps the swarm together. Each boid looks for nearby neighbors, calculates their average position, and applies a steering force toward that local center. This prevents particles from drifting too far away from the group and helps maintain a readable swarm shape while still allowing individual variation in motion.
Bellow is a example of how the behavior can vary by changing these three parameters:
Avoidance & Fallow Leader
The Environment Avoidance module keeps the swarm from clipping through the level geometry. It uses the Global Distance Field to detect nearby surfaces and generate a push direction away from obstacles.
When a boid gets close to the environment, it samples the distance field and applies an avoidance force based on how close it is to the surface. The closer the boid is, the stronger the correction becomes.
This allows the swarm to react naturally to walls, floors, rocks, and other large environment shapes without needing manual collision setup for every particle.
The Follow Leader module gives the swarm a high-level target to move toward. The leader position is passed into Niagara as a user parameter, usually driven by Blueprint or gameplay code.
Each boid calculates a direction from its current position to the leader and adds that as a steering force. This keeps the swarm controllable while still allowing the local boid rules, like separation, alignment, and cohesion, to create organic motion around that target.
In practice, this module acts as the main art-direction and gameplay control point for the system.
Morph Module
The Morph module is responsible for transitioning the swarm from free boid movement into a controlled formation or target shape.
Each boid receives or calculates a target position inside the desired shape, then blends its current movement toward that position. Instead of instantly snapping into place, the particles gradually reduce their flocking behavior and increase their morph influence over time.
This allows the swarm to keep its organic motion while forming a readable monster silhouette.
Additional Credits:
Epic Advanced Niagara system preview