Spawn Niagara particle?

Simple question, what is the Niagara equivalent of this?


UGameplayStatics::SpawnEmitterAtLocation(world, particle, transform);

Just trying to spawn 1-time effects (like explosions) in the world without having a component. Can’t find any way to spawn niagara emitters.

1 Like


UNiagaraFunctionLibrary::SpawnSystemAtLocation(...)


4 Likes

Thankyou :slight_smile:

Hey how does this work?

include “NiagaraFunctionLibrary.h”

gives me the error:
Cannot open include file: ‘NiagaraFunctionLibrary.h’: No such file or directory

I tried adding:
include “Niagara/NiagaraFunctionLibrary.h”
include “Plugins/Niagara/NiagaraFunctionLibrary.h”

Same error. I’m not sure what I’m doing wrong?

Do you have the plugins turned on?

Yeah they’re turned on, and I can access in the content assest window.
Do i need to change something in my VS project?

Oh, did you add it to your .uproject?

{
“FileVersion”: 3,
“EngineAssociation”: “4.25”,
“Category”: “”,
“Description”: “”,
“Modules”:
{
“Name”: “MaulProto”,
“Type”: “Runtime”,
“LoadingPhase”: “Default”,
“AdditionalDependencies”:
“Core”,
“Engine”,
“ProceduralMeshComponent”,
“RenderCore”,
“RHI”,
“PhysicsCore”,
“Text3D”,
"Niagara"
]
}
],

1 Like

AH! I didnt… I dont remember seeing this ANYWHERE in the docs lol
I googled and click through so many Unreal “welcome to niagara” stuff - but they all seemed BP related :frowning:
Is there a bit I’m missing to see an example of a c++ version of this?

Is it normal, that my AdditionalDependencies only has “Engine” ? I see youve got Core, for example…

Also, how do I know when I need to add to this array?
Is this separate (or does it allow for more) include xyz?
Is there an obvious part of the docs I can keep an eye out for?

Sorry last question.
VS compiles fine now.
But my “include “NiagaraFunctionLibrary.h”” has a red squiggle under it with “cannot open source file”.
And when i write the codes:


UNiagaraFunctionLibrary::SpawnSystemAtLocation();

Red squiggle under “UNiagaraFunctionLibrary” and saying “name followed by ‘::’ must be a class or namespace name”

I assume these are related, and not actually an issue, just my VScode being funky?

Cheers!

1 Like

Anytime you are adding a new module or system to your, you’ll need to make sure it’s in there. But usually not very often.

I don’t really know any documentation, it was just something I figured out reading other people’s posts asking about linker errors. I think I was trying to get ProceduralMeshComponent working.

As long as it compiles, you’re fine. The red squiggles just mean that VSCode can’t find the header, but the actual compiler can just fine. If you use the Unreal command to regenerate the project files, it might go away after Unreal includes the appropriate header paths in the project.

2 Likes

Man that is so evil. That you have to know to do that… thats… wow.

2 Likes