Turning a particle effect on and off with code

Hey, me and my fellow classmates are working on a small project for school and we need to be able to turn a fire particle effect on and off with the press of a key. Any ideas on how to get this started or where to look for resources?

  • Thanks

Make the effect and atach it to your character (or where ever you need it).

then:

(java)

var FireEffect : Transform;

function Start () {

FireEffect.renderer.enabled = false;
}

function Update (){

if (Input.GetKey ("f")){

   FireEffect.renderer.enabled = true;
}
else {
   
  FireEffect.renderer.enabled = false;
}
}

Another suggestion. If you have a reference to the particle emitter, you can set property emitt to false. It will stop the emission of particles and the remaining will be on the screen as long as their energy allows them to be.

Writing renderer.enabled = false will stop rendering that object in the next frame. It will look like the object has just been teleported. Setting emitt to false will look like the source of the fire, or particles, has stopped and the effect will slowly (depending on the max energy of the particles) fade away.

thats nice dart. I didn’t have that in mind :smile:

Thanks all. That worked great :smile: Your help is really appricated!