Hey all, I have a UE5.0 project and I’m trying to play a Niagara particle system from C++. However, the very first step - just adding an include for NiagaraSystem.h
- leads to a very weird issue:
NiagaraScript.h(977): [C2666] 'FNiagaraVariable::operator ==': 2 overloads have similar conversions
I’ve tried searching around, but nothing close to the above error unfortunately. In addition, I’ve tried the following:
- Added “Niagara” to build.cs dependencies. (This is required as get compile issues regarding not finding
NiagaraSystem.h
) - Verified Niagara plugin is enabled (which seems to be on by default in UE5 projects)
- Made sure no other code is referencing Niagara whatsoever in my project
In addition, here are my included modules at the moment:
PublicDependencyModuleNames.AddRange(new string[]
{
"Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "CableComponent", "AkAudio", "Niagara"
});
The error seems to imply there are multiple conflicting implementations in some way, but can’t find out where they’re coming from. Have been searching around and trying to debug this for a while, but my only guess at the moment is that this is an engine bug- which would be insane given how prevalent Niagara is now yet there’s no searchable instance of this issue at the moment.
Does anyone have any idea on how to get simple Niagara includes to compile? Appreciate any and all help on this issue!
Edit:
Found a hint from this wonderful answer here. In short, if I don’t include any Niagara headers (eg, no explicit NiagaraSystem.h
or NiagaraFunctionLibrary.h
includes) and use a forward declared class, then the UPROPERTY compiles and works as expected.
For example:
UPROPERTY(EditDefaultsOnly, Category = "Fx Setup")
TMap<RenderEventVFXType, class UNiagaraSystem*> mVFXEventMapping;
However, the moment I try to use any normal Niagara includes in my cpp files (such as #include "NiagaraFunctionLibrary.h"
to spawn the system) then I face the same compile issues again.
Need to investigate further. As a side note, adding “Niagara” to build.cs modules is still required.