4.22 Niagara and C++

Hey, I’m trying to use a particle system component in C++, but I can’t figure it out. I tried adding Niagara to my build.cs, but that just crashes the game. I already have the plugin installed, I just can’t find a way to include the classes into my classes

Post the crash report. What platform are you building on?

1>------ Skipped Build: Project: UE4, Configuration: BuiltWithUnrealBuildTool Win32 ------
1>Project not selected to build for this solution configuration
2>------ Build started: Project: , Configuration: Development_Editor x64 ------
2>Creating makefile for DGDFantasyEditor (no existing makefile)
2>Parsing headers for DGDFantasyEditor
2> Running UnrealHeaderTool “C:\Users\OneDrive\Desktop\.uproject” “C:\Users\OneDrive\Desktop\Intermediate\Build\Win64\DGDFantasyEditor\Development\DGDFantasyEditor.uhtmanifest” -LogCmds=“loginit warning, logexit warning, logdatabase error” -Unattended -WarningsAsErrors -installed
2>C:/Users//OneDrive/Desktop//Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableActor.h(47): error : Unrecognized type ‘FVRClientAuthReplicationData’ - type must be a UCLASS, USTRUCT or UENUM
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets(44,5): error MSB3075: The command ““C:\Program Files\Epic Games\UE_4.22\Engine\Build\BatchFiles\Build.bat” DGDFantasyEditor Win64 Development -Project=“C:\Users\OneDrive\Desktop\.uproject” -WaitMutex -FromMsBuild” exited with code 5. Please verify that you have sufficient rights to run this command.
2>Done building project “.vcxproj” – FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 1 skipped ==========

VS Error: MSB3075
The command ““C:\Program Files\Epic Games\UE_4.22\Engine\Build\BatchFiles\Build.bat” DGDFantasyEditor Win64 Development -Project=“C:\Users\OneDrive\Desktop\.uproject” -WaitMutex -FromMsBuild” exited with code 5. Please verify that you have sufficient rights to run this command. C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets 44

Just built again and was unable to reproduce the error, but I still do not have access to Niagara System Compenent

There you go. The type ‘FVRClientAuthReplicationData’ must be appropriately declared. It is skipping the VRExpansionPlugin in the build, or so it seems. But that is besides the point. In the OP you also mentioned

Have you tried How to Enable the Niagara Effects Plugin in Unreal Engine | Unreal Engine 5.3 Documentation?

Ah, that’s code from another plugin, must’ve not been compiling correctly, because I can’t reproduce that error anymore. So it’s no longer an issue.

The real problem that I’m having:

For the Niagara plugin, everything works great when using blueprints, but, I can’t find the UNiagaraComponent header file that I need to include in my C++ code. My first attempt was to add Niagara to build.cs, but unless the files were added under a labyrinth of sub-folders, I still can’t include it. For base engine components I just include “Components/” whatever I need, but it doesn’t seem to be the same for Niagara. I thought the headers would be exposed outside of any subfolder like other plugins I’ve used before, but I still cannot find it.

I’m assuming UParticleSystemComponent.h is only for Cascade

Ok, the question is now clear. The Niagara files are present in Engine/Plugins/FX/ so it is natural to use the directive as follows


#include "Engine/Plugins/FX/Niagara/Source/Niagara/Public/NiagaraComponent.h"

in order to include the Nagara headers. I couldn’t find the UNiagaraComponent.h though.

Weird. It’s returning with the following error:
c:\projects\source\public\Rune.h(6): fatal error C1083: Cannot open include file: ‘Engine/Plugins/FX/Niagara/Source/Niagara/Public/NiagaraComponent.h’: No such file or directory

It looks like the only files within Engine/ is Classes, Public, Private

Ah, you must also consider the relative path scheme (it is confusing, maybe experienced coders can help), try …/Engine or …/…/Engine. But before that just do a manual search for the header file in the directory.

There are two directories with the same name Engine :D. One is inside Runtime (the one you have mentioned), the other one is 3 levels up!

Literally just came to the forums about to post this exact problem!
BUT I just realized it’s a plugin, and thus the problem isn’t including a path from niagara, it’s how to include a path from plugins!
After a short plugin googling, here’s how you get it working:

Build.cs - Include the Modulename as you know, but also **the Includepath **so unreal knows where the files actually are.



PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore", "Niagara" });

        PublicIncludePaths.AddRange(new string] {
            Path.Combine(ModuleDirectory, "your other paths"),
            Path.Combine(ModuleDirectory, "Niagara")
        });


Now the header from the last Niagara folder will now work!



#include "Niagara/Public/NiagaraComponent.h"


Goodluck!

1 Like

Ok, now it says no reference to Niagara in my project. But the plugin is within the Engine itself in program files

Ok I have no clue what IDE you are using (I am assuming VS), but QT Creator “dynamically” runs the code and notifies you if the file mentioned in the directive is found then and there. Make sure you have run generateprojectfiles script and Niagara files are mentioned in the UE4Headers.pri or something.

I have never seen any files named .pri.
Let me get this straight.
I add “Niagara” to the .build.cs file
I add the path
Then mess with something called UE4Headers.pri and it should work?
what is UE4Headers.pri. Whenever I look it up I only get 3 results, this post being one of them

Is there any documentation at all that I can look at

Hi there,

I was making a new plugin which use UNiagaraComponent and UNiagaraSystem. But It’s return me a error “warning plugin does not list plugin “Niagara” as a dependency but module depends on”

To solved it i had to change some parameters in .cs and .uplugin

MyPlugin.uplugin

I added the Plugins parameters and set Niagara plugin true


{
{
"FileVersion": 3,
"Version": 1,
"VersionName": "1.0",
"FriendlyName": "MyPlugin",
"Description": "",
"Category": "Other",
"CreatedBy": "BlackBirdStudios",
"CreatedByURL": "",
"DocsURL": "",
"MarketplaceURL": "",
"SupportURL": "",
"CanContainContent": true,
"IsBetaVersion": true,
"Installed": false,
  "Modules": 
    {
      "Name": "NiagaraSystemSongEvent",
      "Type": "Runtime",
      "LoadingPhase": "Default"
    }
  ],
  "Plugins": 
    {
      "Name": "Niagara",
      "Enabled": true
    }
  ]

}


MyPlugin.Build.cs
Add Niagara into PublicDependencyModuleNames



PublicDependencyModuleNames.AddRange(
            new string]
            {
                "Core",
                "Niagara"

                // ... add other public dependencies that you statically link with here ...
            }
            );


That solution is when you want make a new plugin wich depends from others

I hope this help