Hey all, I'm new to Arrays and I've got my script spawning 1 enemy every wave but I wanted to make it so that the script will spawn +1 enemy every new wave (Wave 1 = 1, Wave 2 = 2, etc.) but I'm not sure how. Would someone mind making my script do that and explaining what they did so I can use it again in the future?
Just add a for loop around the spawning code:
Instead of just
You can write
This will loop that piece of code as many times as the wave you're on. Since you've also put your spawn locations and enemies in arrays, you can change the indexes to for example Enemies[i], using the iterator for the loop (the counting variable) to spawn the enemy in location 0 of your array in the first wave, the enemies at locations 0 and 1 at the second, locations 0, 1 and 2 for the thrird wave and so forth, since the foor loop starts counting the i at 0 and continues up as long as it's smaller than WaveNumber. For this you need to make sure to have as many added enemies in your array as waves though. =)
answered Aug 21 '11 at 04:42 AM