Play button not playing the game. BIG PROBLEM(Solved)
Today i loaded my project and nothing worked. the only thing i changed without testing the day before was adding a bool to a script that changed the players color.
Today when i hit play all of the codes run through their start functions then stop. the only script that is working is the color changer. everything else seems frozen in time.
I have tried disabling all the scripts except game controller and the problem persists.
I have looked over my code for hours and haven't found any issues with it. everything just stops for no reason. Please help.
UPDATE: more debugging has found that the update sections are only called once.
Game controller script.
 public GameObject[] hazardList;
 public GameObject restartButton;
 public int hazardCount;
 public int hazardCountIncrease;
 
 public float hazardSpeed;
 public float speedIncrease;
 public float startWait;
 public float spawnWait;
 public float waveWait;
 public Vector3 spawnArea1;
 public Vector3 spawnArea2;
 public Vector3 spawnArea3;
 public Text scoreText;
 public Text highScoreText;
 public Text gameOverScoreText;
 private bool gameOver;
 private float score;
 private GameObject hazard;
 void Start ()
 {
     restartButton.SetActive(false);
     gameOverScoreText.text = "";
     highScoreText.text = "";
     scoreText.text = "Score: " + 0;
     gameOver = false;
     StartCoroutine(HazardWaves(spawnArea1));
     StartCoroutine(HazardWaves(spawnArea2));
     StartCoroutine(HazardWaves(spawnArea3));
 }
 
 IEnumerator HazardWaves(Vector3 spawnArea)
 {
     yield return new WaitForSeconds(startWait);
     while (true)
     {
         //Base wave spawner
         for (int i = 0; i < hazardCount; i++)
         {
             GameObject hazard = hazardList[Random.Range(0, hazardList.Length)];
             Vector3 spawnPosition = new Vector3(Random.Range(spawnArea.x, spawnArea.x + 15), spawnArea.y, spawnArea.z);
             Quaternion spawnRotation = Quaternion.identity;
             Instantiate(hazard, spawnPosition, spawnRotation);
             yield return new WaitForSeconds(spawnWait);
         }
         hazardCount = hazardCount + hazardCountIncrease;
         hazardSpeed = hazardSpeed += speedIncrease;
         yield return new WaitForSeconds(waveWait);
         if (gameOver == true)
         {
             break;
         }
     }
 }
 void Update()
 {
     if (gameOver == false)
     {
         score = Time.timeSinceLevelLoad;
         scoreText.text = "Score: " + score.ToString("f2");
     }
     if (gameOver == true)
     {
         scoreText.text = "";
         gameOverScoreText.text = "Score: " + score.ToString("f2");
     }
 }
 // commented this section out to try and fight the bug but even with this gone the game stops after the start section.
 //public void GameOver()
 //{
 //    restartButton.SetActive(true);
  //   gameOver = true;
 //    Time.timeScale = 0;
 //}
 public void ResartGame()
 {
     score = 0;
     Time.timeScale = 1;
     Application.LoadLevel(Application.loadedLevel);
 }
 void SetHighScore(float score)
 {
     if (PlayerPrefs.HasKey("highScore"))
     {
         if (PlayerPrefs.GetFloat("highScore") <= score)
             PlayerPrefs.SetFloat("highScore", score);
     }
     else
     {
         PlayerPrefs.SetFloat("highScore", score);
     }
 }
 
               Color Changer script.
 public bool isRed;
 public Renderer colorRenderer;
 void Start ()
 {
     isRed = false;
 }
 
 void Update ()
 {
     if (Input.touchCount > 0)
     { 
         if (Input.GetTouch(0).phase == TouchPhase.Began)
         {
             isRed = !isRed;
             if (isRed == true)
             {
                 colorRenderer.material.color = Color.red;
             }
             else
             {
                 colorRenderer.material.color = Color.blue;
             }
         
         }       
     }
 }
 
              I guess check your public floats startWait, spawnWait and waveWait and see if they are big.
Each is 3 seconds but that doesn't explain why the other scripts that are completely separate stop as well. I have tried starting the game with obstacles spawned in and they all stop after a frame of movement. the script for moving is separate and confined to the hazard
If you have an IEnumerator without a yield, it will halt the entire game as Coroutines are not asynchronous. Check all yours and make sure they contain a yield.
Answer by LuckierBread · Jul 16, 2016 at 03:32 AM
So i never figured out what went wrong and stopped my player, but i tried making a new project then copying the assets folder from the first project and then loading the scene in that folder.
Now everything works.
If someone figures out what the issue was i would love to hear it so i can hopefully avoid it in the future.
Your answer