- Home /
Best way to spawn new particles
I have to spawn particles at lots of different (and each time new) points. At the moment I do that with the following script:
void ShowParticles(Vector3 position) {
if (!particleSystem) return;
ParticleSystem ps = (ParticleSystem)Instantiate(particleSystem);
ps.transform.position = position;
ps.Play();
Destroy(ps.gameObject, ps.startLifetime);
}
Is there a more efficient way to do this? The amount of particle emitters in my scene is getting too damn high.
What number of emitters are we talking about? You need to specify your situation more.
Have you profiled? It might not be the amount of emitters, but the amount of particles that slows it down.
It could be in the hundred (emitters/points to emit at), typically though 20-30 at the same time. What I did now is to use Emit((int)ps.emissionRate) and just move the emitter before emitting. What I'm still missing is that whenever the maximum of particles is achieved, there can't come any new ones - however this is what I actually need - new ones should always be allowed but older ones should be deleted if maximum number of particles is reached. Is that an option?
Your answer
![](https://koobas.hobune.stream/wayback/20220613105653im_/https://answers.unity.com/themes/thub/images/avi.jpg)