UE學(xué)習(xí)筆記(One)
2023-07-22 12:19 作者:抓狗大隊(duì)隊(duì)長Tager | 我要投稿
UEC++代碼內(nèi)實(shí)現(xiàn)Nigara粒子生成
老粒子生成方法:UGameplayStatics::SpawnEmitterAttached();
需要包含頭文件
#include "Kismet/GameplayStatics.h"
Nigara粒子需要在Build.cs文件中進(jìn)行模塊加載
同時(shí)需要填寫包含路徑(Nigara模塊在引擎目錄下的插件當(dāng)中)
PrivateIncludePaths.AddRange(
new string[]
{
"UE_5.0/Engine/Plugins/FX/Niagara",
}
);

并在需要使用生成Niagara的列中添加頭文件
#include "NiagaraFunctionLibrary.h"
并使用方法
UNiagaraFunctionLibrary::SpawnSystemAttached();
參數(shù)填入示例:
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是會(huì)報(bào)紅的,但是能夠編譯過。
標(biāo)簽: