Loading...
Loading...
Create and control VFX in Unreal Engine 5 with Niagara: systems and emitters, modules and the spawn/update stages, exposed User parameters, and spawning or driving effects from Blueprints or C++. Use when building particle effects, NS_/NE_ assets, spawning a Niagara system at runtime, setting User parameters, or when the user mentions Niagara, VFX, or a particle system in Unreal.
npx skill4agent add gamedev-skills/awesome-gamedev-agent-skills unreal-niagaraNS_NE_NS_NE_UNiagaraComponentshader-programmingaudio-designNS_NE_SystemEmitterParticleUserUNiagaraFunctionLibrary::SpawnSystemAtLocationSpawnSystemAttachedUNiagaraComponentActivateDeactivate#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=RedbAutoDestroy = falseDeactivate()https://dev.epicgames.com/documentation/en-us/unreal-engine/overview-of-niagara-effects-for-unreal-engineUNiagaraFunctionLibraryUNiagaraComponentNiagara*.Build.csshader-programmingunreal-cpp-gameplayunreal-blueprints