Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

game progression

Discussion in 'Scripting' started by Bashplank, Feb 7, 2015.

  1. Bashplank

    Bashplank

    Joined:
    Jan 7, 2015
    Posts:
    9
    How can I make a game harder over time (in one scene)?
     
  2. kaarme

    kaarme

    Joined:
    May 1, 2014
    Posts:
    177
    What type of game? Add more and harder enemies with more health and attack damage or any new abilities, make dropping platforms and stuff like that.
     
    Kiwasi likes this.
  3. Bashplank

    Bashplank

    Joined:
    Jan 7, 2015
    Posts:
    9
    Its an infinite 3D arcade game where you play as an paper plane, avoiding all obstacles. To be more precise, how can I make the obstacles faster and in more numbers over time (in terms of code)?
     
  4. kaarme

    kaarme

    Joined:
    May 1, 2014
    Posts:
    177
    Show your code.
     
  5. Bashplank

    Bashplank

    Joined:
    Jan 7, 2015
    Posts:
    9
    Code (CSharp):
    1.     IEnumerator SpawnWaves ()
    2.     {
    3.         yield return new WaitForSeconds (startWait);
    4.         while (true)
    5.         {
    6.             for (int i = 0; i < hazardCount; i++)
    7.             {
    8.                 GameObject hazard = hazards [Random.Range (0, hazards.Length)];
    9.                 Vector3 spawnPosition = new Vector3 (Random.Range (-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);
    10.                 Quaternion spawnRotation = Quaternion.identity;
    11.                 Instantiate (hazard, spawnPosition, spawnRotation);
    12.                 yield return new WaitForSeconds (spawnWait);
    13.             }
    14.             yield return new WaitForSeconds (waveWait);
    15.          
    16.             if (gameOver)
    17.             {
    18.                 restartText.text = "Touch to Restart";
    19.                 restart = true;
    20.                 break;
    21.             }
    22.         }
    23.     }
    This determines the spawning of the obstacles (there are 4 types). Would I need to make a separate piece of code for each of the obstacles?
     
    Last edited: Feb 8, 2015
  6. ReeVee

    ReeVee

    Joined:
    Feb 3, 2014
    Posts:
    5
    Try increaseing your hazardCount after each wave of hazards.
     
  7. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,353
    When wave starts, increase hazardCount.

    In other words as wave starts increase max number of enemies in the game or increase speed.
     
  8. Bashplank

    Bashplank

    Joined:
    Jan 7, 2015
    Posts:
    9
    Sorry, I'm pretty new to C#. How can I write "after Wave ends, increase hazardCount by 5"?
     
  9. kaarme

    kaarme

    Joined:
    May 1, 2014
    Posts:
    177
    You should seriusly read all the scripting manual sections and learn to understand that code. So first you need to know when wave ends, and that is in the end of the while loop after "waveWait". Add some space to the end by clicking space after the code in line 20 and press enter. Then write to the new line hazardCount = hazardCount + 5;

    Welkome to Unity and have fun with with learning :D