Some of you may have noticed a bug in the last demo where occasionally enemies wouldn’t appear. This week, I’ll be writing about the process I went through to find out what caused the bug and fix it.
The first clue was that it only seemed to affect Trotties (the pink enemy that walks back and forth) and other moving enemies. This meant that it was likely something related to their return script.
I had made it so that enemies, when both they and their initial position are offscreen, teleport back to their home so as to keep them reliably placed during speedruns.
My next step was to run the game in debug mode. This allowed me to check information about objects as the game ran, specifically their position and speed. When I checked a Trotty’s vertical speed, I saw that their speed was way, way higher than it should be (like thousands higher).
I checked the return script and found that it was only returning the enemies to their home as opposed to returning them and resetting their speed. This meant that they could build up speed for as long as they weren’t onscreen. When the player entered and area that allowed the enemy to be onscreen, one of two things would happen: either the enemy would not have enough speed to clip through the ground, and they would collide with it, resetting their speed; or the enemy would clip through the ground if it had enough speed. The enemy would not be able to teleport back to its home, since its home was onscreen and visible to the player.
I plan on releasing an updated version of the alpha next week with this bug removed, along with a few other improvements. ‘Til then!
0 comments