Shuriken particle system : disable and re-enable emitter

Hello everyone,

I am currently stuck using the particle system on Unity 3.5

My character is able to switch between 2 weapons, by throwing them out of the screen. These weapons have a particlesystem attached to them.

What I want is to stop emitting when the weapon isn’t used. It seems easy, but using

Stop();

or

enableEmission=false;

are making the particles already emitted disappear. I could work with that, but it’s not as pretty as it could be.


Worse, when I get the disabled weapon back, using

Play();

or

enableEmission=true;

make those disappeared particles reappear at the exact point they were when I disabled the emission.


All I can do is use

Clear();

To remove those invisible, unsimulated particles. But they still disappear strangely.

I would like to know if there is a way to :

  • Disable emission without deleting the particles.
  • Reenable emission from the beginning (Simulate(0f) doesn’t work).

Thanks.

Perhaps you can use particleSystem.Emit(int count) in the update function?

Shuriken is a little different to the old particle system…this is how i did it:

Start by making a variable:

var beam : ParticleSystem;

function Start(){

//this will make the particle system usable in function Update
beam = GetComponent(ParticleSystem);

//this clears the particle system when you start the game...use it if you like
beam.Stop();
beam.Clear();

}

function Update(){

//This will start the particles playing when you press the left mouse button
if (Input.GetMouseButton(0)){
	beam.Play();
        }

//This will stop the particle system when you let go of the button
if (Input.GetMouseButtonUp(0)){
	beam.Stop();
	beam.Clear();
	}

}

Attach the script to the particle system, and drag the same particle system into the ‘beam’ variable.

Hopefully this gives you an idea of how the particle system can be stopped and started

If you have 2 particle systems, just use 2 variables (beam & beam2 for instance)

Not used to answering questions, let me know if anything is unclear :slight_smile: