Niagra particle effect spawning issue

I can’t find an official UE4 example/tutorial on how to do this in c++.

So far I’ve got:




#include "NiagaraComponent.h"
#include "NiagaraFunctionLibrary.h"

// Character init
NSDust = LoadObject<UNiagaraSystem>(nullptr, TEXT("/Game/A_Surface_Footstep/Niagara_FX/ParticleSystems/PEN_General1_Dust.PEN_General1_Dust"), nullptr, LOAD_None, nullptr);

// Character Jump
UNiagaraFunctionLibrary::SpawnSystemAtLocation(GetWorld(), NSDust, location, FRotator::ZeroRotator, FVector(5, 5 ,5));
// GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, NSDust->GetName());



Nothing appears…? :S
If I uncomment the DebugMsg() it crashes when the game reaches that line.

Struggling to work out best to debug why it’s not spawning. But perhaps I’ve completlly misunderstood how I should be doing this?

Any pointers would be greatly appreciated

Maybe the “NSDust” isn’t valid and the particle system failed to load.

BTW, this way of loading objects worked for me so far in every case except with Niagara particle system.



// Setup references
static ConstructorHelpers::FObjectFinder<UNiagaraSystem> LclMapLvlLoc(TEXT("/Game/Particles/MapLvlLoc/MapLvlLoc"));
MapLvlLoc = LclMapLvlLoc.Object;


So, the work around that I use is wraping the the Niagara system into UNiagaraComponent in an actor class, which gets inherited by a Blueprint class, where I assign the the Niagara system and then spawn the Blueprint class instead.

Yeah I read others had success by doing similar. To be clear, youre created a custom actor with a NiagraComp, then creating a BP - and setting the Niagra component inside the Editor, saving. Then in your c++ you reference this new BP and spawn that?

Just seems like this should be do able without the BP step, right ?

Yep, exactly.

Yes, if you could get Niagara particle system reference in C++, which seems to fail in this case.