Using Niagara particles and vfx in Unreal C++; covering first time set up - UE C++ Tutorial

preview_player
Показать описание
Here's how to use Niagara assets in C++. Covering Gotchas, BP differences, setting up linker, compile errors, including, and the important IsValid distinction.
IsValid should be used to determine when particles are no longer valid, not != nullptr.
This is because a particle can finish playing before the garbage collector frees the pointer to its component (if it is set to destroy).
So the != nullptr will be delayed, compared to IsValid.
When you check if a niagara component is valid in bluerpint, it is doing something more like the IsValid function, rather than the != nullptr check.

I hope it helps. I tried to cover the flow for the first time using niagara, and how to properly set up your project (or plugin) to use it as a dependency.

Recorded in 5.4

0:00 What we are building
0:25 Blueprint Niagara Particle Spawning
1:25 Setting up niagara particle spawning in code
1:45 Setting up overlap virtual
2:06 Setting up a spawned UNiagaraComponent actor component uproperty
2:55 Use IsValid, do not use != nullptr
3:52 Spawning niagara in code
4:22 UNiagaraSystem property in code
4:42 Setting the arguments of UNiagaraFunctionLibrary::SpawnSystemAttached
5:45 Assigning to our NiagaraComponent UNiagaraComponent property
6:00 Fix up logging
6:13 Overlap Summary
6:30 Writing code to compare IsValid to != nullptr in tick
8:14 Preparing for compile
8:29 Compiling
8:38 error C2065: 'UNiagaraSystem': undeclared identifier
9:26 error C2653: 'UKismetSystemLibrary': is not a class or namespace name
10:00 error C2065: 'UNiagaraComponent': undeclared identifier
10:37 fatal error C1083: Cannot open include file: 'NiagaraSystem.h': No such file or directory see declaration of 'NIAGARA_API'
10:55 Setting up Niagara module as a dependency
10:49 error C2653: 'UNiagaraFunctionLibrary': is not a class or namespace name
12:14 error C2143: syntax error: missing ';' before '}'
12:34 populating the niagara system asset into the code property
13:12 Testing client vs server
13:20 PIE testing system spawning
13:41 Debugging the tick c++ code
14:05 Helper to determine if we are debugging dedicated server or the client
14:16 Comparing IsValid vs != nullptr in the debugger
15:30 Testing out spawning only when isvalid is false (and != nullptr is true)
15:58 Summary of everything learned
17:07 Outro
Рекомендации по теме
visit shbcf.ru