Unit3d enable particle system

I am trying to turn the created particle system on and off.
I attached it to the collection.

The code I use 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 before fps when the key is held down and stops playing when it is pressed.

+4
source share
2 answers

Try using:

 waterGun.Play(); 

and

 waterGun.Stop(); 

And also your logic is upside down, as Joetja said.

+5
source

You say that it is assigned a โ€œWaterGun assemblyโ€, but you must assign an instance of the particle system in the waterGun scene, not the assembly. There is no collection on stage.

0
source

Source: https://habr.com/ru/post/1469067/


All Articles