Day 12. Bug fixing. Player Ammo. Wave System

Dmitry Gordeev
2 min readNov 29, 2020

--

While I keep working on core programming, bugs are not sleeping. I mean software bugs. I am trying to deal with them right away, but sometimes you can discover a hidden one that shows you did it wrong, and in the case to fix it, a programmer needs to find another approach with a better solution. Here starts a timed race, where you just want to find a quick solution and move on, but that bug is still here.

To make it easy and safe time, a programmer can use special tools and techniques. One of them is Debug.Log(variable); which will print a value in the console. Another more powerful tool is breakpoints. MS Visual Studio connected to Unity by default setup. Just put a red breakpoint in the line of code and run the game. The runtime will pause when it reaches the chosen line. Eventually, you can look at the current state of variables. Make a step forward and see what changed. It is way easier to debug when you can see the whole picture. That was the basics of debugging.

Let’s look at the Ammo count visualizer. I made it as a slider. It reflects the current and max amount of ammo.

As you can notice, the wave system became spawning enemies. The spawn manager starts to wait until the player will kill all enemies and spawn last +1 in the next wave.

--

--

Dmitry Gordeev
Dmitry Gordeev

No responses yet