Unity Tutorial: How to Create a Wave Spawner

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 ม.ค. 2025

ความคิดเห็น • 33

  • @codecodile
    @codecodile  ปีที่แล้ว +3

    1:23 It has to be public in order to work! :D
    Scripts:
    github.com/cCodecodile/TH-cam/tree/69a7526422829834325b1001e8545fab1b31e8df/Tutorials/WaveSpawner/Scripts

  • @ignatiusreilly8280
    @ignatiusreilly8280 10 หลายเดือนก่อน +1

    Thank you so much. I wish every tutorial on TH-cam had such methodical and thorough explanation.
    To keep track of enemies: I used to call an event which fired when an enemy died, and the counter in another class looked at that event, to keep track. Your way is more elegant and more organized. Thanks a million, for showing us.

  • @pablovillegas2898
    @pablovillegas2898 8 หลายเดือนก่อน

    This tutorial works awesome, thanks for the tutorial!!!!

  • @satyrn6118
    @satyrn6118 ปีที่แล้ว +1

    Thanks. This helped a lot adding a health system

    • @codecodile
      @codecodile  ปีที่แล้ว

      Glad it helped! :D

    • @docgraal485
      @docgraal485 ปีที่แล้ว

      @@codecodile i am making an fps and I have used different tutorials for help, I cannot find a good tutorial which gives a health system for the player where they would decrease health as they collided with the enemy projectile and for it to be displayed in a text mesh pro ui feature, please can you make a video explaining this because I love how helpful this was. My assignment is due on Thursday this week, no rush but help would be appreciated

  • @Dennis2005
    @Dennis2005 หลายเดือนก่อน

    im getting this error:
    NullReferenceException: Object reference not set to an instance of an object
    Enemy.Update () (at Assets/Enemy.cs:24)

  • @destijl1337
    @destijl1337 10 หลายเดือนก่อน

    Hi, thanks very much for this. I used the array code you provided but my enemies vanish quickly after appearing each wave. Can you point me in the vague direction of what would be causing enemies to be destroyed quickly after they're first instantiated? I have a feeling it's to do with the values I'm inputting into the inspector but I'm not entirely sure - it seems that the waves are ending suddenly then moving onto the next

  • @TheDemoncrater
    @TheDemoncrater ปีที่แล้ว

    ¨Sorry but which script do you want the start function? at 5:14?

  • @evyman7515
    @evyman7515 ปีที่แล้ว +1

    Does anyone know a way I could spawn power ups along with the enemies each round but still only killing the enemies progresses the rounds?

  • @blanketdev7911
    @blanketdev7911 ปีที่แล้ว +1

    hi it says that the index was outside the bounds of the array for each code where I had currentWaveIndex do you know a fix for this problem?

    • @codecodile
      @codecodile  ปีที่แล้ว

      I do not know exactly what the problem is because I do not have the code. Maybe check again if the code you wrote is exactly the same as in the video :)

    • @perdoist3627
      @perdoist3627 11 หลายเดือนก่อน

      Basicly even when the last wave is over it still increases the current wave. So you have to stop the increment after the last wave.

  • @docgraal485
    @docgraal485 ปีที่แล้ว +1

    How do I add a textmesh pro ui feature where it displays the wave number at the begining of each wave?

    • @codecodile
      @codecodile  ปีที่แล้ว +1

      First create the UI in the editor. Then just set the text of this to the currentWaveIndex in the Update function.
      Then you write some code before you spawn the enemies. Just activate the text object, wait an amount of seconds(I recommend using Coroutines, but you can also just create a simple timer for that) and then disable it again :)

  • @Assassinpatrik
    @Assassinpatrik 6 หลายเดือนก่อน

    hi, kannst du mir helfen bei mir wir das ihn der console ausgeführt

  • @spinospine
    @spinospine 10 หลายเดือนก่อน

    Thanks for the video ❤how do i adjust the scripts so that the waves are infinite and that there's the same wave of enemies each time?

  • @Sinbad1999
    @Sinbad1999 10 หลายเดือนก่อน

    i followed the tutorial but when i press play and the countdown goes down to 0, an infinite amount of enemies spawn in and lags the entire project. Any way i can fix this?

    • @nuclear270
      @nuclear270 10 หลายเดือนก่อน

      me too

  • @fr3sh80y8
    @fr3sh80y8 2 หลายเดือนก่อน

    My code is the same, but all enemies spawn at once :(

  • @TheAntox007
    @TheAntox007 ปีที่แล้ว +2

    Yeah for me the problem is that It does not see the list at all, like it will spawn the first element from the first array and say that the level is finished, I am currently Debugging to see where the problem is

    • @kentanggaming0386
      @kentanggaming0386 ปีที่แล้ว

      can share your code ? pls

    • @TheAntox007
      @TheAntox007 ปีที่แล้ว

      @@kentanggaming0386 i made workaround where I set 5 waves with firat empty then 3 of them work, and the last is empty so the code for finishing activates whrn the last wave spawnes but is empty

    • @yasuomain5942
      @yasuomain5942 10 หลายเดือนก่อน

      @TheAntox007 Use {System.Serializalbe} to show it in the Inspector

  • @ARIEL-xf8gg
    @ARIEL-xf8gg ปีที่แล้ว

    mine is doesn't generate the other wave's, the output just the first wave, can u give any advice?
    so my program doesn't increase following the currentWaveIndex, idk why thoo.. i have following all in this video

    • @codecodile
      @codecodile  ปีที่แล้ว

      I do not understand your problem completely. Could you be a little bit more specific what exactly isn't working?

  • @chaz4949
    @chaz4949 ปีที่แล้ว

    trying to add it to another health script the part with the countdown, but it wont let me put the "waveSpawner.waves[waveSpawner.curentWaveIndex].enemiesLeft==;" part in as it says that ; is an invalid term

  • @Robert-rh8dh
    @Robert-rh8dh ปีที่แล้ว +1

    Hey enyone know how to fix a glitch where if two projectiles kill the same target at the same time it counts as 2 kills messing up the whole enemiesLeft counter

    • @elicentric
      @elicentric 8 หลายเดือนก่อน

      i have the same problem but im not using projectiles

  • @sketchturner8229
    @sketchturner8229 10 หลายเดือนก่อน

    Hello! Thanks for the tutorial.
    I Cant understand whats wrong, all made like you. (Im new in scripting :))
    UnassignedReferenceException: The variable spawnPoint of WaveSpawner has not been assigned.
    You probably need to assign the spawnPoint variable of the WaveSpawner script in the inspector.
    WaveSpawner+d__6.MoveNext () (at Assets/Scripts/Enemy/WaveSpawner.cs:41)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at :0)
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    WaveSpawner:Update() (at Assets/Scripts/Enemy/WaveSpawner.cs:33)

    • @chellminn
      @chellminn 10 หลายเดือนก่อน

      I had the same problem. In order to fix it, click your Wavespawner in the Hierarchy. If you then look in the Inspector you'll see beneath Countdown a line with Spawn Point and None (Game Object). From the Hierarchy drag your Spawnpoint in here. If I'm not mistaken that should fix the problem.

    • @sketchturner8229
      @sketchturner8229 10 หลายเดือนก่อน

      @@chellminn Hey! ) Ye, forgot to say, i fix the problem, wasn't referenced )))
      Thanks for the comment, it can help others))