Search Unity

Need Some Help Thinking Through The Process To Create Waves

Discussion in 'Scripting' started by imaginethepoet, Aug 30, 2018.

  1. imaginethepoet

    imaginethepoet

    Joined:
    Aug 23, 2016
    Posts:
    44
    Good Afternoon;

    I'm a little stuck in the thought process on my game and could use a little help kickstarting me in the right direction. Essentially I want to break the game into a series of 3 timed waves. I'm tripping up on starting because I don't know really how I should do this. I'm thinking the code should be on a game object that is called something like gameflow and then be a while loop with exits when game over, or a wave has ended. Any direction you might have would be appreciated.
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,779
    I thought you are meant sea waves ...

    I am a bit confused what you really need and what you know already.
    For me, you should start from very basics. Look up on tutorials.
    You need create logic for your waves, which can be executed from MonoBehaviour inherited class, which is assigned to GameObject.

    But is no point me going into this, since you need very basics first.
    Take a pad, and draw up you general logic by hand, of what you want.
    Then start coding and making you methods accordingly.

    Do tests of each component step by step.
     
  3. imaginethepoet

    imaginethepoet

    Joined:
    Aug 23, 2016
    Posts:
    44
    I know quite a bit: I'm just looking for a way that someone might do this. I have drawn this up before, but I'm trying to think If I am on the right path before I go down the wrong path.

    Logic wise I know

    1. I want to break each level into waves
    2. The waves will start at the beginning of the game and on game over reset
    3. If a wave is completed they move to the next wave
    4. If they wave is failed (by death game over is called)

    I was initially thinking about putting a script on an object and just calling that game flow, and breaking the waves up in there. I'm not sure if that's the right direction.
     
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,779
    There is no single way of doing things right.
    Your basics structure looks ok.

    But personally I would simply have GameLevelManager class, which will monitor when level/wave ends and control, triggering another level/wave. Possibly with difficulty properties, etc. Other class will be responsible for wave itself, which gets the difficulty properties and initiate wave accordingly. When done, send status back to GameLevelManager.
     
  5. newjerseyrunner

    newjerseyrunner

    Joined:
    Jul 20, 2017
    Posts:
    966
    I have something similar. I spawn all of the enemies at once. I have them grouped in their waves and disable all except the first wave. I have a script that counts the number of living objects in the current scene and triggers the next wave once the count reaches 1 (or 2 in some cases.)