I have a feeling this is an easy thing, but I cant seem to figure it out. I have a car that I want to emit a small cloud of exhaust when you hold down the gas button. This part is working fine. However I would like to limit the emitter time to just 1 or 2 seconds. So each time you hit the gas button you get a poof of exhaust.
Here is my code. No errors, it just doesn’t stop emitting after 1 second.
var emitter : ParticleEmitter;
function Update () {
exhaustEmitter ();
}
function exhaustEmitter (){
if(Input.GetKey("w")){
emitter.emit = true;
yield WaitForSeconds(1);
}
else{
emitter.emit = false;
}
}