- Home /
Particle System Optimization (.IsAlive but more efficient)
Hello,
I am currently making a game with a lot of particle systems that need to be in place to allow lots of entities to use them simultaneously. This means that there are about 500 particle emitters in total. I have them running from an object pool to reduce garbage collection, so I disable them after they finish running instead of using Destroy. However, I've run into a bit of a problem. Checking whether each particle effect is done every single frame is extremely slow. I have to disable them when they finish because otherwise they cause even more lag than checking every frame. So here's my question: How can I achieve the same effect without running .IsAlive in Update for each particle? As I said before, I am using object pooling, so I can't use Destroy (x time) on its creation. I could skip some frames for the .IsAlive checks, but I'm worried that this will only help a little because it's still running checks every frame (albeit much cheaper ones). I could also run the checks from an overhead script or something, but that would only help so much, and with such a large number of particles, it might be even slower to access their particle systems every frame. Is there a way I could use Unity's event system here to speed this up, or some equivalent system? Is it even possible to avoid this issue, or am I just going to have to design around it?
Thanks in advance, The Koala Squad.
Sounds like a good use case for the New Entity Component System.
Thanks for the tip! I’ll test this out when I get the chance.
I've spent a couple days learning how to use ECS and implementing it in place of the current systems, and I don't think it's going to work. Strangely enough, the ECS version actually runs slower than the normal version. $$anonymous$$aybe I'm just doing it wrong, and that would be reasonable enough, considering that this is the first time I've ever touched ECS. I tested it a little and recorded approximate FPS counts. The $$anonymous$$ax is with no particles being used, and the $$anonymous$$ is with most or all of them.
ECS System - 525 $$anonymous$$ax, 150 $$anonymous$$in. Normal System - 550 $$anonymous$$ax, 210 $$anonymous$$in.
Anyway, thanks for the help. It didn't work out for me, and I can't tell whether it's Unity's or $$anonymous$$e, but thanks anyway! At least I had an excuse to check out ECS for the first time.
Oh too bad.
How many kinds of particles are there? Are the particles all unique, or are there multiple emitters for the same kind of particle?
Answer by richardkettlewell · Apr 21, 2019 at 07:35 PM
How about https://docs.unity3d.com/ScriptReference/ParticleSystem.MainModule-stopAction.html ? (Can set via the Inspector or via script)
Your answer
Follow this Question
Related Questions
Optimize Particle Emitter with Massive # of Particles 0 Answers
Is shuriken well performing on iDevices? (iPhone, iPad) 1 Answer
What slows down my game? 1 Answer
Improving script performance 1 Answer