In my spaceship game, the players spaceship has a boolean variable for whether or no the ship is boosting. if that variable is true, the particle emitter on the ship’s engines sets its variable particleEmitter.emit to true or false accordingly.
But whenever particleEmitter.emit is set to false, the gameObject deletes it’s self.
function Update ()
{
if ((GameObject.FindWithTag("Player").GetComponent(ShipControl) as ShipControl).boosting)
particleEmitter.emit = true;
else
particleEmitter.emit = false;
}