UE学习笔记(One)
2023-07-22 12:19 作者:抓狗大队队长Tager | 我要投稿
UEC++代码内实现Nigara粒子生成
老粒子生成方法:UGameplayStatics::SpawnEmitterAttached();
需要包含头文件
#include "Kismet/GameplayStatics.h"
Nigara粒子需要在Build.cs文件中进行模块加载
同时需要填写包含路径(Nigara模块在引擎目录下的插件当中)
PrivateIncludePaths.AddRange(
new string[]
{
"UE_5.0/Engine/Plugins/FX/Niagara",
}
);

并在需要使用生成Niagara的列中添加头文件
#include "NiagaraFunctionLibrary.h"
并使用方法
UNiagaraFunctionLibrary::SpawnSystemAttached();
参数填入示例:
UNiagaraFunctionLibrary::SpawnSystemAttached(GunVFX, Gun, TEXT("Muzzle"), FVector(0.f, 0.f, 0.f), FRotator(0.f, 0.f, 0.f), EAttachLocation::KeepRelativeOffset, false, true, ENCPoolMethod::None, true);
PS:这样写VS是会报红的,但是能够编译过。