I have a custom projectile management system based on C++ Unreal Engine subsystem class, it manages projectile positions in the pool and its locations. To visualize projectiles I use Niagara (mesh renderer). Before for visuals I used separate actors, after replacing it with Niagara I got an awesome performance boost (I went up from 2 000 projectiles to 25 000 with the same frame rate. WOW!!!).
There are few problems:
I can not manage particle spawn directly as I do for actors. For AActors I just kill or spawn an actor right away when I add it to the pool at any moment. But I can not directly add a particle to Niagara, I have few options here:
- Turn off “kill particles”, and just reuse them, this is what I do now. In this case I would just set alpha to 0 for all unused projectiles and place them somewhere in the far corner of my level, or turn distance culling. Maybe there are better options to exclude particles from rendering, which seems like the “Renderer Visibility” parameter would do, but I’m not sure how to use it.
- Kill unnecessary ones and spawn new on demand by Spawn Burst Instantaneous passing dynamic parameter every iteration. In this case projectile spawn in Niagara would happen once in a loop so it is async to game, and in this case I will always have different amounts of projectiles in my pool and in niagara.
Since this is one way CPU->GPU I doubt it is possible to sync particle amounts and I have to always have some reserved ones in Niagara. Also, there should not be direct connection between elements and particles. For example first frame I draw my projectile at index 5 with particle at index 5, next frame I delete 3rd projectile and it my projectile would move from 5 to 4 and I will visualize it with particle at index 4 despite it was represented with different particle in previous frame.*
To pass data I have to use the Vector Array interface, but I would love to pass my custom type struct Projectile”. As I researched I would need a data interface for that, making last is very complicated.
Maybe you can share some thoughts on that and suggest other ways of implementing this. As I searched the forum I came across the topic discussing the possibility of manipulating a single particle, as I understood it’s not possible.
Maybe you can share some articles on scripting with Niagara, I did not find much. If there is an expert in this field I would love to hire him for this task of teaching me. Any help would be appreciated.