Devlog #9

Bugs Be Gone

Posted October 15, 2023

Programming Woes

There comes a moment in programming in which you realize an answer was under your nose the whole time. Sometimes you find it, and sometimes you don't. Fortunately, today I was able to find the bug that stopped my development for 2 weeks.

I'm Blind

When you use an unused parameter in a function, the debugger asks you to prefix it with an underscore. Since I'm used to using the physics process function for testing, I added an underscore to prevent this debug error. And since I'm conditioned to do this, I also did it to a very important variable within my range function.

With the help of a good friend of mine who is also a developer, and we just so happened to be talking about Godot/Game Dev. When I mentioned this bug that's been stumping me lately, we started to reanalyze the problem. After explaining the bug, solutions I've tried, and a tad more debugging, he suggested I try to use "body.global_position".

And then it clicked. I hadn't been using the body variable because I put an underscore in front of it and forgot about it. By using the body variable, I now have the exact coordinates of each body entering the range.

And just like that, it was working. Sort of. It is a tad hard to see in the GIF, but the weapon sprite is now turning towards each enemy.

Fine Tuning

Even while writing this devlog I'm still ecstatic that this bug has finally been squashed. I was almost about to post a thread in the Godot community discord for help too. OK, back on topic.

Now that the weapon sprite turns properly (FINALLY), I need to debug why the tip of the weapon is not pointing correctly. To temporarily replace the weapon sprite, I made a gigantic arrow sprite to help with that. To isolate which side was turning, my friend suggested to coloring both sides to determine this.

Forest

With this setup, we figured out the right side (green) of the arrow was doing the pointing. After a little rotating, we found that 90 degrees gave the sought-after effect. And now it works!


Next Devlog: #10 ›

Thank You

A sincere & huge thank you to my friend Nick for helping me with this bug. Sometimes all you need is someone to point out the simple things right in front of you. I find it very funny how programming is like that sometimes.

Check him out: His GitHub