Particle system activation issues.

I’m a Unity and scripting newbie and I’m stuck. I’m trying to create a fire extinguisher effect when I hold down the fire button, and when released, it stops.

I don’t think I need it instantiated, as it’s just on or off, not duplicating itself. Using the CreateParticleSystem.js as an example, I deleted the parts of the script to tell the particles where and how to emit from on a surface.

function Update () {
// Did the user press the mouse button?
if (Input.GetMouseButtonDown (0)) {

Instantiate (particleSystem);
}

}

But this doesn’t work, I just get an error-is there an easy way to turn the particles on/off per mouse button activation that I missed?

My goal is to run around using my fire extinguisher to extinguish objects that are on fire. Any other tips or hints??

Try this on your particle system:

function Update ()
{
     if (Input.GetMouseButtonDown (0))
          particleEmitter.emit = true;

     else if (Input.GetMouseButtonUp (0))
            particleEmitter.emit = false;
}

And in case it’s not obvious, you’ll need to create the particle system yourself ahead of time, and then attach this script to it. Make sure that the ParticleEmitter’s “emit” field is unchecked in the inspector, otherwise your fire extinguisher will be spraying when the game starts.

Hi guys, thanks!! This rules. Now it totally makes sense, I just need to get more familiar with scripting and js.
Much appreciated!!
Brian