x


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.

more ▼

asked Mar 08 '11 at 05:05 PM

Ozy gravatar image

Ozy
18 4 6 8

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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 =).

more ▼

answered Mar 08 '11 at 05:35 PM

Justin Warner gravatar image

Justin Warner
6.3k 19 27 65

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.

Mar 08 '11 at 06:30 PM Ozy

Oh, I had this problem before... Make 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?

Mar 08 '11 at 11:20 PM Justin Warner
(comments are locked)
10|3000 characters needed characters left

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).

more ▼

answered May 13 '11 at 02:46 PM

PrimeDerektive gravatar image

PrimeDerektive
3.1k 57 64 84

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x785
x659
x356
x353
x232

asked: Mar 08 '11 at 05:05 PM

Seen: 3237 times

Last Updated: Mar 08 '11 at 05:05 PM