I have a particle system that contains multiple children particles. Is there anyway I can make sure the top parent particle end last? (so that I can make use of the stop action Callback)
Thanks.
I have a particle system that contains multiple children particles. Is there anyway I can make sure the top parent particle end last? (so that I can make use of the stop action Callback)
Thanks.
Well, there are various ways to archive this, but I will provide you the easiest way to implement.
First, let’s talk about the idea. The idea here is set your Explosion Smoke 's loop to true, then start a coroutine to check if all the children isAlive, if not, stop the Explosion Smoke, and the StopAction will be invoked.
public class TestParticle : MonoBehaviour {
private ParticleSystem m_mainps;
private List<ParticleSystem> m_childrenPar;
ParticleSystem.MainModule m_main;
private void Start() {
m_mainps = GetComponent<ParticleSystem>();
m_childrenPar = GetComponentsInChildren<ParticleSystem>().ToList();
m_main = m_mainps.main;
m_main.loop = true;
m_main.stopAction = ParticleSystemStopAction.Destroy; // or something else
StartCoroutine(OnFinish());
}
private IEnumerator OnFinish() {
yield return new WaitUntil(() => !m_childrenPar.Exists(x => x.IsAlive()));
m_mainps.Stop();
}
}
attached this script to your particlesystem object maybe it’s work.
Cheers, Vince.