- Home /
Making a cloned particle emitter fire once only
Alright, well, I have this particle emitter prefab seperate from the gun enitity,
var Poof : Transform;
function OnCollisionEnter( ){
var clone : Transform;
clone = Instantiate(Poof, transform.position, transform.rotation);
Destroy(clone, 0.5) ;
}
However I want the cloned prefab to disappear after a set amount of time.
For now, it just continually repeats.
The script clones the prefab and I want the cloned prefab particle emitter to be destroyed after it runs it's 1 second course.
Answer by Justin Warner · Mar 08, 2011 at 05:35 PM
On the particle prefab, their is a thing called Autodestruct, which'll make it destroy itself once it does the full animation.And then put on One Shot, and it'll do it right.
Alternatively, you could do the yield WaitForSeconds (Check API).
Hope this helps! Any questions, ask =).
But that destroys the actual prefab, I want the clone of the prefab to disappear after a set amount of time after the impact. I tried the autodestruct and that destroys the parent prefab, rendering the clone spawning useless.
Oh, I had this problem before... $$anonymous$$ake a copy below the map, then copy from there? Or you can just enable it and disable it, or move it under the ground after it shoots. Or you can disable the autodestruct, and try that?
Answer by PrimeDerektive · May 13, 2011 at 02:46 PM
Instantiating one-shot particle emitters that self-destruct is generally a bad idea, because its going to result in a lot of unnecessary drawcalls.
It's better to make your particle system a one-shot system that is set to not emit at all by default (or by setting .emit to false in Start()) and hiding it somewhere in the scene, and then positioning and rotating the emitter at the point of impact you want the effect to be, then calling the particleEmitter.Emit() function (which will make it emit once).
Your answer
Follow this Question
Related Questions
Trying to destroy a projectile and "teleport" to another area of the screen when it hits a target. 1 Answer
How to destroy an instantiated prefab in C#? 4 Answers
Audio and Particles on Trigger 0 Answers
Blocking particles then destroy then reduce health 0 Answers
Help me to manage game memory 1 Answer