- Home /
How to control particle lifetime when emitting programmatically?
Hello,
I'm using the ParticleSystem's Emit function to emit my particles but I can't seem to find a way to set the lifetime or control other properties which can be set if using the emitter pane, is this possible?
Thanks!
like this?
var someParticle : ParticleSystem;
function Start () {
someParticle.startLifetime = 1;
}
It seems like I'm unable to post comments right now (JavaScript errors in console), so I'll answer here:
I tried that however it doesn't seem to affect my particles when they are emitted with "ParticleSystem.Emit()".
However, I think my problem might actually be lying in the Emit method cause it seems it has a lifetime parameter...
Answer by KevinCodes4Food · Dec 19, 2013 at 08:13 PM
Try creating a public ParticleSystem variable in a script, then in the Unity editor select the GameObject with the ParticleSystem you wish to control.
Then you can edit the ParticleSystem variable's properties:
public ParticleSystem particleSystem;
void Start()
{
particleSystem.startLifetime = 3;
particleSystem.startSize = 2;
...
particleSystem.Play();
}
Unfortunately that didn't seem to work when emitting particles manually, it seems like I had to manually delete them as well.
Your answer
Follow this Question
Related Questions
How to make camera position relative to a specific target. 1 Answer
Separate particle systems with duplicate behavior? 0 Answers
How to make particles react to movement of particle system 4 Answers
Shuriken particle system - changing the emitter mesh programatically 2 Answers
Particles emmiting all over the shape, is it possible make them spawn gradually from a set point? 0 Answers