- Home /
Recycling particle emitter leaves particles in 2 locations instead of 1
I have a blood splatter system to reuse the blood splatter particle effects so I don't have to instantiate/destroy them all the time. I have an array of 5 game objects with blood particle effects attached. the problem is when I reuse one of them the blood effect appears in both the new location and the old location (well a slightly diminished version in the old location).
If I instantiate and destroy it all works fine. but I want to recycle the pool of objects. I just set the new position and set emit to true. Why does the effect when reused show up in 2 positions? how do I fix it? And no I don't want to instantiate and destroy to fix it.
Do you start emission before or after the particle system is in its new location?
Answer by rutter · May 25, 2012 at 07:36 AM
Moving an emitter will not necessarily disable or alter any particles it has already emitted. This is actually very important -- suppose you have an NPC carrying a lit torch, would you want the character's movement to also move any smoke or sparks the torch is emitting?
If you're using Shuriken particles, you might try calling Clear() on the ParticleSystem to "reset" it before starting emission.
If you're using Unity's legacy particles, there is a very similar ClearParticles() method for the ParticleEmitter.
Answer by Kameesabee · Aug 24, 2013 at 05:30 PM
Nope, this doesn't seem to fix it on my end. I'm using the new shuriken system. Do you deactivate the game object when it is being stored?
Answer by JohnPoison · Apr 09, 2015 at 10:54 AM
I was able to solve this problem with following code
// required to fix a bug of unity when it doesn't clear all the particles and its position
ps.Simulate(0f, true, true);
ps.Stop(true);
ps.Clear(true);
ps.Play(true);
Important note: you should call this code right after you reuse particles, and ONLY after you have updated the transform of your particle system.
Also I notice that such problem appears only with world-space simulation particles.
Your answer
Follow this Question
Related Questions
Recycling particle system 1 Answer
Android: FPS halt when doing things for the first time 2 Answers
Immortal enemies when reanimated, or pooled game objects re-activated do not respond to collisions? 1 Answer
Freeze lag with object pool/recycler, why? 2 Answers
Turning on and off Particle effects 2 Answers