title: All health hearts disappear,not one by one, when timer countdown hits zero
body: <p>I have created a maze game with 3 health hearts and a timer countdown. when the timer reaches zero, it is supposed to subtract one heart and give additional 30 seconds before subtracting another one. when the player is on the last heart and the timer reaches zero, the game will be over. </p>
  
  <p>My problem is that when the timer reaches zero, it erases all my health bars and the game ends. Another was that the timer countdown grants the additional 30 seconds and all the hearts are gone and the timer does not show the 30 seconds on the text and the game does not end. </p>
  
  <p>I created two scripts, one for health called LifeHeart.cs and one for timer called Loading.cs. I am new to unity so I implemented these codes from various sources and made them my own. The loading.cs shows that when the timer seconds is 0 and the timer minutes is 0, it is supposed to minus one heart and add an additional 30 seconds and start the coroutine. In the Lifeheart.cs there is a switch case showing when there is one heart subtracted, it is supposed to remove one heart by setting it to false.</p>
  
  <p>I researched and I found that others have said that the static variable is the reason that all the health hearts gets erased, so I changed the way to call the variable to gameobject.find, but that still doesn't work. to make the timer countdown to grant the additional 30 seconds, I commented the "Time.timeScale = 0;" in the case 0 in LifeHeart.cs, it grants the 30 seconds but the hearts are all wiped out and the text on the timer does not show the 30 second countdown.</p>
  
  <p>This is the first script of the code from my LifeHeart.cs- the comments are the ways i was trying to make it work</p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class LifeHeart : MonoBehaviour
  {
      public GameObject heart1;
      public GameObject heart2;
      public GameObject heart3;
      public static int health=3;
  
      // Start is called before the first frame update
      void Start()
      {
  
          health = 3;
          heart1.gameObject.SetActive(true);
          heart2.gameObject.SetActive(true);
          heart3.gameObject.SetActive(true);
      }
  
      // Update is called once per frame
      void Update()
      {
          if (health &gt; 3)
              health = 3;
  
          switch (health)
          {
              case 3:
                  heart1.gameObject.SetActive(true);
                  heart2.gameObject.SetActive(true);
                  heart3.gameObject.SetActive(true);
                  break;
  
              case 2:
                  heart1.gameObject.SetActive(true);
                  heart2.gameObject.SetActive(true);
                  heart3.gameObject.SetActive(false);
                  break;
  
              case 1:
                  heart1.gameObject.SetActive(true);
                  heart2.gameObject.SetActive(false);
                  heart3.gameObject.SetActive(false);
                  break;
  
              case 0:
                  heart1.gameObject.SetActive(false);
                  heart2.gameObject.SetActive(false);
                  heart3.gameObject.SetActive(false);
                  //Time.timeScale = 0; //to make the extra 30 sec to work
                  break;
          }
      }
  }
  
  //---------------------------------------------------------------------
  //and this is second script of the code from my timer called Loading.cs
  //---------------------------------------------------------------------
  using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using UnityEngine.UI;
  
  public class Loading : MonoBehaviour
  {
      public Image loading;
      public Text timeText;
      public int minutes;
      public int sec;
      int totalSeconds = 0;
      int TOTAL_SECONDS = 0;
      float fillamount;
  
      void Start()
      {
          timeText.text = minutes + " : " + sec;
          if (minutes &gt; 0)
              totalSeconds += minutes * 60;
          if (sec &gt; 0)
              totalSeconds += sec;
          TOTAL_SECONDS = totalSeconds;
          StartCoroutine(second());
      }
  
      void Update()
      {
          //GameObject gameControl = GameObject.Find("GameControl");//name of my gameobject
          //LifeHeart LifeHeart = gameControl.GetComponent&lt;LifeHeart&gt;();
          if (sec == 0 &amp;&amp; minutes == 0 &amp;&amp; LifeHeart.health&gt;0)
          {
              LifeHeart.health -= 1;
              totalSeconds += sec + 30;
              TOTAL_SECONDS = totalSeconds;
              StartCoroutine(second());
          }
  
          else if (sec == 0 &amp;&amp; minutes == 0 &amp;&amp; LifeHeart.health == 0)
          {
              timeText.text = "Time's Up!";//this one activates instead of showing the 30 seconds on the timer
              //Time.timeScale = 0;
              StopCoroutine(second());
          }
      }
      IEnumerator second()
      {
          yield return new WaitForSeconds(1f);
          if (sec &gt; 0)
              sec--;
          if (sec == 0 &amp;&amp; minutes != 0)
          {
              sec = 60;
              minutes--;
          }
          timeText.text = minutes + " : " + sec;
          fillLoading();
          StartCoroutine(second());
      }
  
      void fillLoading() // this is the code for the image of the timer clock
      {
          totalSeconds--;
          float fill = (float)totalSeconds / TOTAL_SECONDS;
          loading.fillAmount = fill;
      }
  }
  </code></pre>
  
  <ul>
  <li><p>1st problem: all health hearts disappear and game stops</p></li>
  <li><p>2nd problem: all health hearts disappear, but timer grants 30 seconds but does not show on timer text</p></li>
  </ul>
  
  <p>I am sorry if I have made any mistakes. Your help is greatly appreciated</p>