Build and control real-time visual effects in UE5 with Niagara: understand the System/Emitter/Module hierarchy, expose parameters you can drive from gameplay, and spawn effects at runtime. Targets UE 5.8. (Niagara replaces the legacy Cascade system.)
NS_) and Emitters (NE_), wiring modules in the
spawn/update stages, exposing User parameters to gameplay, or spawning/driving an effect
(impact, muzzle flash, fire, magic) from Blueprint or C++.NS_/NE_ assets or references UNiagaraComponent.When not to use: material/shader authoring (the look of a surface, not particles) is a
separate topic; shader-programming covers cross-engine shader concepts. Audio for the effect
→ audio-design.
NS_) is the effect you place/spawn; it
contains one or more Emitters (NE_, often emitter templates). Each emitter runs in
stages: Emitter Spawn/Update, Particle Spawn/Update, optional Event Handler, and
Render.System, Emitter, Particle, and User. Only
User-namespace parameters are exposed to and settable from Blueprint/C++; the others are
internal to the simulation.UNiagaraFunctionLibrary::SpawnSystemAtLocation (world position)
or SpawnSystemAttached (follows a component/socket), which return a UNiagaraComponent.Activate/Deactivate it.#include "NiagaraFunctionLibrary.h"
#include "NiagaraComponent.h"
// ImpactSystem is a UPROPERTY(EditAnywhere) TObjectPtr<UNiagaraSystem>.
void AProjectile::SpawnImpact(const FVector& Location, const FRotator& Rotation)
{
UNiagaraComponent* FX = UNiagaraFunctionLibrary::SpawnSystemAtLocation(
GetWorld(), ImpactSystem, Location, Rotation);
// FX auto-destroys when finished for a one-shot (system marked non-looping).
}
UNiagaraComponent* Muzzle = UNiagaraFunctionLibrary::SpawnSystemAttached(
MuzzleSystem, WeaponMesh, FName("MuzzleSocket"),
FVector::ZeroVector, FRotator::ZeroRotator,
EAttachLocation::SnapToTarget, /*bAutoDestroy*/ true);
// Only User-namespace parameters can be set from gameplay. Names match the User parameter.
if (UNiagaraComponent* Fire = UNiagaraFunctionLibrary::SpawnSystemAttached(
FireSystem, RootComponent, NAME_None, FVector::ZeroVector, FRotator::ZeroRotator,
EAttachLocation::KeepRelativeOffset, /*bAutoDestroy*/ false))
{
Fire->SetVariableFloat(FName("SpawnRate"), 250.f); // User.SpawnRate
Fire->SetVariableLinearColor(FName("FireColor"), FLinearColor::Red);
}
Spawn System at Location (System = NS_Impact, Location, Rotation) -> returns Niagara Component
On the returned component:
Set Niagara Variable (Float) Name="SpawnRate" Value=250
Set Niagara Variable (LinearColor) Name="FireColor" Value=Red
bAutoDestroy = false and never
Deactivate()d; manage the returned component's lifetime, or mark the system non-looping for
one-shots.https://dev.epicgames.com/documentation/en-us/unreal-engine/overview-of-niagara-effects-for-unreal-engine)
and the UNiagaraFunctionLibrary / UNiagaraComponent API. Add the Niagara module to
*.Build.cs for C++ access.shader-programming — material/shader concepts for particle materials.unreal-cpp-gameplay — spawning effects from gameplay code and module setup.unreal-blueprints — triggering effects from visual scripts.