Turning A Particle On Off

How would you go about making a particle become active via a button press.
I already have the button pressing down. But how would I make a particle come on.

The emit property?

Yes.

Do you want it to come from a certain point? Or wherever the player clicks?

To make a particle appear in a certain place.

  1. Create the particle, adjust the proporties to get the particle effect you want. you may want to check ‘self destruct’ and ‘one shot’ in the settings.
  2. Once your done adjusting the particle, make a prefab of it.
  3. create a empty gameObject.
  4. Create a javaScript code, and assign the javascript to the gameObject.

Here is what you need to put in the javascript code.

var particle : Transform;
function Update () {

if(Input.GetMouseButtonDown(0))

Instantiate (particle,transform.position,transform.rotation);
}
  1. Once thats done, you will notice another column under the javascript in the inspector. It should say none (transform). Drag the particle prefab onto those words.

  2. run the game and click on the left mouse button. It should spawn the particle every time you click.

Awesome thanks. It’s for my sidescroller. When your next to the shower it has to come on with E so…

Just replace Input.GetMouseButtonDown (0) with Input.GetKeyDown (“e”);