Why would ParticleSystem.Stop() not work from another script?
I’m calling the function from a gameobject that is NOT on the particle system. However, the other functions I do call for that particle system are reacting nicely, so it is definitely not a reference problem. It’s just ParticleSystem.Stop(); doesn’t want to work.
When I do:
void OnParticleCollision(){
ParticleSystem.Stop();
}
it works fine! No issues! But it doesn’t react when I call it from a different script… Here is a screen shot of the main timing information of my particle system.
What am I doing wrong? And is there some other function I can call which will stop the particle system that isn’t
ParticleSystem.Stop (true, ParticleSystemStopBehavior.StopEmittingAndClear);
?
Because that does stop it, but it also stops my subemitters from playing, and continues to do this weird clearing pattern until the duration is done anyway, should the particle get called to run again.
All I want is to call ParticleSystem.Stop(); from another script and have it react without the OnParticleCollision function, but it’s either a unity glitch, or I’m way off base with how to control these things.
even if I get the component and call it without a reference it doesn’t work, but it will work just fine in the onparticlecollision function. Very weird!
EDIT, ISSUE RESOLVED
I have scrapped the use of subemitters, because YOU NEED VELOCITY FOR THEM TO WORK, and personally that is not within my interests for this particle. So I have succumbed to a sphere collider for this collision system.
I have learned that ParticleSystem.Stop(); will stop the particle AFTER its stated duration / start time, while the aforementioned ParticleSystem.Stop (true, ParticleSystemStopBehavior.StopEmittingAndClear); will stop the particle outright. So for trails and stuff, I use the former, and for things I wanna stop immediately, I use the latter.
You can also use ParticleSystem.Stop (false, ParticleSystemStopBehavior.StopEmittingAndClear); if you want to immediately stop the parent, but not the children.
Hope this helps anybody else struggling out there.