Tower Defense WaveDowmCounter
Hi Guys. I’m new to Unity so I started learning from YT tutorials. A month ago I started Tower Defense tutorial from brackeys and I think I’ve done quite good job as I added few features on my own. However I can’t figured out how to add wave down counter which will count how many waves left in scene and once next wave is spawned I want this number to go -1. Can somebody help with this please? I wouldn’t be posting here if I wouldn’t try to search or try to do it on my own. Thanks
Answer by highpockets · May 02, 2020 at 06:44 AM
This will work:
int waveCounter = 40;
float waveTimer = 30.0f;
void Update(){
waveTimer -= Time.deltaTime;
if(waveTimer <= 0.0f){
waveTimer = 30.0f; //reset waveTimer
//new wave code
waveCounter -= 1; //subtract 1 from waveCounter
if(waveCounter == 0){
//all waves finished
}
}
}
Your answer
Follow this Question
Related Questions
CountDown List Prefabs 0 Answers
Infinite wave spawner help 0 Answers
How do i make my enemies follow the waypoints in my tower defense game 0 Answers
Start and Stop Timer Help 1 Answer
How to start and stop timer when player colide with gameobject? 0 Answers