Search Unity

Bug ParticleSystem.isPlaying seems to be broken

Discussion in 'Editor & General Support' started by SoftwareGeezers, Oct 27, 2021.

  1. SoftwareGeezers

    SoftwareGeezers

    Joined:
    Jun 22, 2013
    Posts:
    902
    I've had a terrible time getting my flame-thrower to work. When the item is instantiated and first activates, the particle system won't play.

    Having gone through the motions, I've found that the reporting from isPlaying seems completely whack. I present a public boolean isParticlesPlaying within the script and in FixedUpdate I set this boolean to whatever ParticleSystem.isPlaying is:
    Code (CSharp):
    1.  
    2. FixedUpdate() {
    3.      isParticlesPlaying = beamParticles.isPlaying
    4. }
    Enabling and disabling the particle system, this boolean doesn't match whether the particle system is actually active or not. Also I can change the value in the Inspector and it'll stick instead of being updated to the particle system's play state. I can start the test scene, see the particles playing, and see the isParticlesPlaying tickbox checked. I can click the checkbox is disable the tick but then it's immediately set to on as that's what .isPlaying says. But then I can set it to off and the value stays off, even when the particle system is running and beamParticles.isPlaying should be setting it to on. Likewise, I can set the tickbox to on even when the particle system is off.

    In my project proper, once I get the emitter working, a cycle of enable, disable, reenable, it seems to work properly. But this means the first use of the weapon doesn't work and I can't figure out how to get it to work. This isPlaying situation is making me wonder if the fault is actually with Shuriken (2019).

    Edit: Okay, the above behaviour with the checkbox seems to be an Inspector thing as enabling/disabling a GO based on particleSystem.isPlaying seems correct. Sadly leaving me still confused as to why my playing and active particle systems aren't emitting particles.
     
    Last edited: Oct 27, 2021
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    I never turn particle systems on and off... it always seemed to have undesirable effects.

    Instead I just grab the emission module instance and manipulate the rate over time property, setting it down to zero when I want it off.
     
  3. SoftwareGeezers

    SoftwareGeezers

    Joined:
    Jun 22, 2013
    Posts:
    902
    Oh, that sounds like a good plan. At the moment I seem to have it patched by playing then immediately pausing at instantiation. The Play() and Stop() seem to work. But yeah, it's so flaky/unintuitive that your suggestion seems a smart move. Except I guess those system with more complex emission parameters.