i am trying to turn on and off a particle system i created.
I attached it to a prefab.
The code I am using is as follows
public ParticleSystem waterGun;
void Update () {
if(Input.GetKey(KeyCode.W)){
waterGun.enableEmission = true;
}else if(Input.GetKeyUp(KeyCode.W)){
waterGun.enableEmission = false;
}
}
I want the particle system to play in front of the fps when a key is held down and stop playing when it is pressed.
Try using:
waterGun.Play();
and
waterGun.Stop();
And also, your logic is inverted, like Joetjah said.