Particle System Play and Stop not working...2D Shmup

Hi guys!!

I have a 2D Shmup and when my playerCurrentHealth is 1 || 2 (1 or 2) I want aPartSys to Play.() (Loop…) If and when it changes (0 or 3 or more) via power ups, death etc, it resets to Stop() Now, I’ve read that if you Stop or enable it, it looks unnatural. I would agree. I want it to stop then let the last that have been emitted play out as it were so it doesn’t disappear.

Anyway, its not starting or stopping with these C# commands so, I think I may have missed something here.

public void PlayerLowHealthWarn()
    {
        if ((playerCurrentHealth == 2) || playerCurrentHealth == 1)
        {
            playerAnimator.SetBool("LowHealthWarn", true);
           
        else
            playerAnimator.SetBool("LowHealthWarn", false);
            deathSmoke.enableEmission = false;

Thanks in advance!!

You dont have a closing bracket after line 5. Also, you can only do NO brackets only when there is one line after the else. So, if it was just line 8 it would be fine but since you have additional code after the else, you need to add brackets before 8 and after 9. Here:

public void PlayerLowHealthWarn()
    {
        if ((playerCurrentHealth == 2) || playerCurrentHealth == 1)
        {
            playerAnimator.SetBool("LowHealthWarn", true);
         Debug.Log("Player's current health is " + playerCurrentHealth);
         }
        else
        {
            playerAnimator.SetBool("LowHealthWarn", false);
            deathSmoke.enableEmission = false;
            Debug.Log("Stop particles");
         }
     }
1 Like

I added some Debug.Logs so you can see if it calls properly now.

1 Like

Thank you for your replies. I’ll give this ago.

I forgot to put in my code, to turn the system on, then off on the else. Plus, when declaring the particle system, shall I use normal

Public ParticleSystem
Or
Public ParticleSystem.EmissionModule?

Thanks in advance again guys. Your help is muchly appreciated.

public ParticleSystem ps;

1 Like