'one shot' particles with animation

I have problem trying to create an one shot particle system with an animation. It works perfectly when i am working with particles which emits normally but not particles with one shot behaviour

this is what i want to achieve
eg:

i want a firework(particles system set to one shot)to emit once when it’s at frame 100 on the animation graph. How do i go about it?

Don’t forget to set “Autodestruct” to true. :stuck_out_tongue:

haha. i tried but it doesnt work if u have an animation attached to it. the animation is not visible. I am guessing that the reason is becoz the particles got distructed the very next frame. probably that’s y i couldnt the see the animation.

Ah, so you’re animating the actual particle emitter, then? If it’s a one-shot, I’m not entirely sure why you’d need to do so, though.

In any case, what you’d do is uncheck the “Emit” checkbox for the emitter, and in the function you’re firing at frame 100, fire the emitter with either

particleEmitter.Emit();

or

particleEmitter.emit = true;

As I mentioned, though, I’m not sure why you’d need to attach an animation to the emitter if you only need it to fire once. Why not just instantiate it when needed? If it’s meant to fire at a specific point in another object’s animation, then you can fire the event from that object’s timeline.

I was puzzled that this “one shot” didn’t work either, but was told by Unity support (Antenna Tree, I think)
that “one shot” particles only works after you build your scene by design.
Guess I still don’t know why that might be, though I was told, guess I still don’t know why it has to be so.

Hey there. yes yes. i am trying to fire at a specific point in another object’s animation. How do i fire the event from that object’s timeline?

thanks!

I think this is maybe done to simulate atmospheric effects? So you just one shot the particles and then they are there.
For other purposes you must program when the effect turns on and off.

Pretty similar to how you’d fire off the emitter in its own timeline, with the addition of an exposed reference you use to specify the emitter to fire.

//when you add the function via Animation Event,
//you'll be prompted to reference the appropriate emitter prefab
//ensure "Emit","one-shot" and "autodestruct" are enabled in the prefab

var firework:ParticleEmitter;

function Firework() {
  //spawn the emitter at the position of the parent object
  var fireworkClone:ParticleEmitter;
  fireworkClone = Instantiate(firework, transform.position, Quaternion.identity);
}

hey Lotekk

thks for your help. it works!

PS: i am from Singapore too :slight_smile:

I’d like to get this working in the animation timeline so my artist can do it themselves. Imagine an elaborate animation with explosions and fireworks etc all set to go off at certain times in the animation. If one-shot emitters could work in the animation then this could be easily done without scripting and merely calling play on the animation itself.

What happens is the particle emitter “sparkles” for lack of better terminology. And emits all its particles really fast or that’s what it looks like anyway. It would be nice to start with emit=0 be able to set emit=1 at one point in the timeline and have the particle effect happen, then set emit=0 later to turn it off.