This is for the old Particle System method, This has bugged me for years, Over various Unity versions
I look online and see the answer to this question and a lot of people saying, I think the docs also say this.
var ps = GetComponent();
ps.Stop(); ← Does not work, Even the Unity documentation says this should work
or
ParticleSystem.EmissionModule em = ps.emission;
em.enabled = false; ← also Does not work
what actually works, as in stopping the particle system from emitting is
ParticleSystem.EmissionModule em = ps.emission;
em.rateOverTime = 0;
em.rateOverDistance = 0;
So I’m just curious why do people recommend 2 methods that don’t actually work?
Scratching my head here
All three methods do COMPLETELY different things that cause a particle system to stop.
Enclosed is full package, open the scene, press PLAY.
Here is the script. Try it yourself.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// @kurtdekker - all of these methods work just fine but ALL are different things.
public class ZedzPS : MonoBehaviour
{
[Header( "Drag a ParticleSystem into each of these!")]
public ParticleSystem ps1;
public ParticleSystem ps2;
public ParticleSystem ps3;
IEnumerator Start ()
{
yield return new WaitForSeconds( 2.0f);
// method 1: Stops the entire particle simulator
ps1.Stop();
yield return new WaitForSeconds( 2.0f);
// method 2: disables the emission module
{
ParticleSystem.EmissionModule em = ps2.emission;
em.enabled = false;
}
yield return new WaitForSeconds( 2.0f);
// method 3: sets distance and time rates to zero
{
ParticleSystem.EmissionModule em = ps3.emission;
em.rateOverTime = 0;
em.rateOverDistance = 0;
}
}
}
Sorry for not replying earlier. For some reason it takes hours before my threads show up for other people (as in I make a post, come back 8 hours later and it has zero views, its only the next day or so then it has ~40 views or something), so I’ve learn to wait before checking my thread.
I will check out your package (Later today, just some things to do this morning)
You’ve gone above the call of duty mate by making that.
I’m curious to see if it works, like I said I’ve noticed this in multiple versions of Unity for years.
Normally I would assume I’m just doing it wrong as its such an obvious bug that surely 100s of ppl have noticed it before, but its so simple that I don’t see how I’m doing it wrong
if I go
em.enabled = false;
and view the particle system in the inspector, the emission module will become unticked
but it still happily continues emitting particles
the only way to stop emission is to do
em.rateOverTime = 0
em.rateOverDistance = 0;
Its been like this for years on multiple unity versions thus the issue must be me but I’m dammed if I know why.