title: Increase speed levels and spawn rate of each kind of Enemies after certain level
body: <p>I have a unity game script that I want to improve but my basic C terms are making errors.</p>
  
  <p>I want to increase the amount of different Enemy sprites, and include 3 or 4 levels of difficulty by increasing speed and spawn rate for each kind of different enemy sprite after every 3 or 4 levels.</p>
  
  <p>I used </p>
  
  <pre><code>public GameObject enemy;
  public GameObject enemy2;
  public GameObject enemy3;
  
  
  
  
  
  
  
  // Update is called once per frame
      void Update()
      {
          // Handle the back button on Windows Phone 8
          if (Input.GetKeyDown(KeyCode.Escape))
          {
              HandleBackbutton();
          }
  
          spawnNewEnemyTimer -= Time.deltaTime;
          if (spawnNewEnemyTimer &lt;= 0)
          {
              spawnNewEnemyTimer = 5;
  
  
              int spawnNumberOfEnemies = 1 + (level/2);
  
              for (int i = 0; i &lt; spawnNumberOfEnemies; i++)
              {
                  GameObject enemyToSpawn;
                  enemyToSpawn = enemy;
  
                  if (level &gt; 2)
                  {
                      float rndEnemy = Random.Range(0.0f, 1.0f);
                      if (rndEnemy &gt; 0.5)
                      {
                          enemyToSpawn = enemy;
                      }
                      else
                      {
                          enemyToSpawn = enemy2;
                      }
              else
              {
                  enemyToSpawn = enemy3;                 //GIVING ME ERROR HERE
              }
                  }
  
                  float modifier = Random.Range(-1.0f, 1.0f) * 3;
  
                  Instantiate(enemyToSpawn, new Vector3(player.transform.position.x + 20.0f + i * 3,
                         player.transform.position.y + modifier, 0.0f), Quaternion.identity);
              }
  
              float rndPowerupHp = Random.Range(0.0f, 1.0f);
              if (rndPowerupHp &lt; 0.1)
              {
                  Instantiate(hpPowerUp, new Vector3(player.transform.position.x + 30.0f,
                         player.transform.position.y, 0.0f), Quaternion.identity);
              }
  
              float rndBuilding = Random.Range(0.0f, 1.0f);
              if (rndPowerupHp &lt; 0.5)
              {
                  GameObject whatBuilding = building1;
  
                  float rndWhatBulding = Random.Range(0.0f, 1.0f);
  
                  if (rndWhatBulding &gt; 0.5)
                  {
                      whatBuilding = building1;
                  }
                  else
                  {
                      whatBuilding = building2;
                  }
  
                  Instantiate(whatBuilding, new Vector3(player.transform.position.x + 30.0f,
                          0.0f, 0.005f), Quaternion.identity);
              }
          }
  </code></pre>
  
  <p>But it's giving me errors.</p>