Gun fire particles

When i fire my weapon, I want the particle emitter attached to it to have a maximum and minimum emit of 50, which bot reduce so that after about 5 seconds, they are at 0. How would I do this?

378454–13103–$sniperfirebarellend_182.js (178 Bytes)

You can do this quite easily with a coroutine:-

function ReducingEmission() {
  var timeLeft = 5;

  while (timeLeft > 0) {
    var fracTimeLeft = timeLeft / 5.0;
    particleEmitter.minEmission = 50 * fracTimeLeft;
    particleEmitter.maxEmission = 50 * fracTimeLeft;
    timeLeft -= Time.deltaTime;
    yield;
  }
}

Thanks. That works fine.