13{
14 UNiagaraComponent* NiagaraComponent = nullptr;
15
16 if (IsValid(Template) == false || IsValid(MeshComp) == false)
17 {
18 return nullptr;
19 }
20
21 if (Template->IsLooping())
22 {
23 return nullptr;
24 }
25
26
27 if (Attached)
28 {
29 NiagaraComponent = UNiagaraFunctionLibrary::SpawnSystemAttached(
30 Template,
31 MeshComp,
32 SocketName,
33 LocationOffset,
34 RotationOffset,
35 EAttachLocation::KeepRelativeOffset,
36 true,
37 false
38 );
39 }
40 else
41 {
42 const FTransform MeshTransform = MeshComp->GetSocketTransform(SocketName);
43
44 NiagaraComponent = UNiagaraFunctionLibrary::SpawnSystemAtLocation(
45 MeshComp->GetWorld(),
46 Template,
47 MeshTransform.TransformPosition(LocationOffset),
48 (MeshTransform.GetRotation() * RotationOffsetQuat).Rotator(),
49 FVector(1.0f),
50 true,
51 false
52 );
53 }
54
55 if (IsValid(NiagaraComponent) == false)
56 {
57 return nullptr;
58 }
59
60 NiagaraComponent->SetUsingAbsoluteScale(bAbsoluteScale);
61 NiagaraComponent->SetRelativeScale3D_Direct(Scale);
63 NiagaraComponent->Activate(true);
64
65 return NiagaraComponent;
66}