The Art Of Debugging

Over time, every programmer will be faced with countless situations in which they have to figure out “WHY” something is or isn’t performing the actions that are desired. It is in situations like these that proper “Debugging” can save your work and in some cases, your sanity.

To start, there is a simple line of code that can be implemented almost anywhere in your script for use as a triggered identifier.

If you put this line of code in your script, it will type the text that you put in the parenthesis into your Unity Console. With that, you can find where parts of your script are not getting called properly, or even called repeatedly. When you encounter a bug, putting a bunch of Debug.Log statements throughout your script can help you to identify the problem areas.

[Pro Tip]

Before delving too deep into a debug session, it’s always a good idea to toss a copy of your scripts folder onto your desktop or somewhere as a temporary backup just in case things go wrong. Otherwise, you may think a bug to be a quick fix and then find yourself two miles deep without an updated backup to revert to.

Hi, my name is Adam Reed and I am a software engineer specializing in Unity and C# development. Feel free to scroll through and check out some of my work!