Hi guys, I’d really like to know how you’d go about optimizing this? 20 actors each spawning 8 projectiles per 0.1 sec which are then destroyed 0.8 seconds later, all done through blueprints
Gif: Screen capture - eab053741012405926193c6302ef84a7 - Gyazo
I thought about pooling but not sure if it’s okay to have 1000 projectiles on standby since I know spawning and destroying is costly but going though all, picking one to re-locate and initializing the projectile per character might also be a problem, what cha say? other options? I can totally do pooling if that’s the only way
Would really appreciate some tips/practices.
Thank you all!
I’ve recently done something similar. I used to spawn them like you, by Spawn Actor of Class, but since each actor is a separate BP, with 200+ of them I experienced huge performance drop.
So I went ahead and converted the system from spawning actors to spawning components to make use of the UE instancing system. Here’s what it looks like:
So it creates a component that is not attached to anything, simulates physics, and has no gravity affecting it. The component is then launched, and then I bind to the component hit event that allows me to destroy it and affect the actor that it hits.
The Count section adds all the spawned components into an array, and once the number exceeds 250, it starts destroying the components that were spawned first, if they still exist, and newly spawned components take their places in the array.
Overall it resulted in a great performance boost compared to spawning actors.
Neat and only 1 step away from a pooling system.