Devlog #2 - Stupid Bugs 1

Hi there!

As developers know, it's always a frustrating time when a whole day of development time is lost to poor design choices leading so some silly bugs. By working with Unity, which seems geared more towards designers than programmers, I've found myself falling into many traps by trying to design levels and gameplay while paying little attention to the code that has to enforce all these design decisions.

Trying to use solutions in via things like Triggers and Game Objects instead of programmatically has also tripped me up and led to parts of the game being tightly coupled. I started this game in 2017, before I had discovered the Unity code management tutorials from Jason Weimann and the like. 

Huh? Where did my cookie carrier go? I'm hungry!

In the case of this bug, I was testing the boss encounter of the first stage when near the end, the boss would simply disappear, leaving the player stuck and giving me this error in the console. 

I agree Unity -- I should NOT destroy this object. It's not my fault I swear!

This took me a good 4 hours to figure out. I search the entire code base for a Destroy() command on this boss. Found nothing. Became concerned that a 3rd party plugin went rouge (always an inevitable concern as a solo game developer).

Finally, I resorted to ripping out parts of the boss AI logic, wondering if I'd able be able to put them back or if I'd need to remove the game mechanic that it was disappearing on completely. The logic being removed was a LeanTween command that's responsible for having the boss ram the player. The boss would disappear when it left the screen. But, unlike most enemies, the boss doesn't have a script that destroys the Game Object when it leaves the screen. 

So what's destroying it?

Darkness, my old friend

Turns out, it was an old solution that I had recently re-enabled because I thought it was needed. The original problem was that I needed a way to remove enemies from the screen when they are no longer seen by the player, so that I don't have over a bunch of enemy Game Objects floating around behind the player if they weren't killed. This solution was a 3D wall with a trigger that stays behind the player object, off the screen. This wall is (or was) responsible for destroying all enemy Game Objects that passed through it, since most enemies enter at the top of the screen and exit at the bottom. 

I had implemented this before I learned about OnBecameVisible() and OnBecameInvisible(), which the solution I'm using now. 

I had completely forgotten the old solution was still there and that I had re-enabled it awhile ago. I disabled it again, and I plan to do some more thorough testing to see if it's safe to delete ExitCameraViewCollider completely. But, yes, it turns out all I needed to do was disable that object. No code needed to be removed. So that's good. My Boss AI is saved. 

Just wish that hadn't derailed much of my progress for the day. 

Leave a comment

Log in with to leave a comment.