Particle systems in Unity

This video tutorial explains how to use particle systems in your Unity game and also an introduction on how to use C# scripts to control a particle system. Watch the video below and then scroll down to see the sample code.

The sample C# code below shows how to play or stop a particle system when a key is pressed. This code should be placed inside the Update() method.

 if (Input.GetKeyDown (KeyCode.E)) {
 if(gameObject.GetComponent<ParticleSystem>().isPlaying == true){
 gameObject.GetComponent<ParticleSystem>().Stop ();
 }
 else{
 gameObject.GetComponent<ParticleSystem>().Play ();
 }
 }