Little Victories
I wasn’t going to feel good about going to sleep Wednesday evening without really trying my best to figure out some unexpected game bugs that are holding me back. I am happy to report that I managed to solve my main two issues mostly by myself! That was a cause to celebrate, and so I did, with some non-alcoholic ginger beer and a few rounds of Magic the Gathering online at 2am. I get wild, I know. I was still pretty amped after solving my game issues shortly before that, and I knew I would be tired the next day, but whatever. Let’s small kine celebrate!
On to the bugs. At the end of the tutorial series there was a bug where enemies would destroy themselves upon spawning. Basically, they were firing lasers into themselves for immediate suicide. The fix provided in the video was that the enemy was still using the direction assignment of the player laser. The laser was moving up, rather than down. I went in my script and changed the appropriate direction, but the bug persisted. Fast forward. After moving the instantiate points (where they appear on screen) of the laser to be far away from the ship so I could see what was happening, I noticed that there was yet another laser firing from somewhere! I had one laser firing through code only, and another laser parented to the enemy ship, firing in the opposite direction. Once I deleted the laserPrefab from the parent ship, I was back to only one laser, and it was moving in the right direction. One other problem was the placement of the enemy laser upon instantiation. I want it to instantiate pretty close to the enemy ship to have a good “look”, but it was hitting the collider and exploding the enemy ship as soon as it appeared. Until this point all lasers in the game had the same tag of “Laser”. My team lead recommended changing the tag on the enemy laser to “Enemy Laser” for clarity, so I did. That actually fixed the problem of enemies hitting other enemies as well as themselves, but they could still hit the player and vice versa. Perfect. All fixed up!
My main issue was losing my powerups for some unknown reason. My console was telling me that there was an unhappy array somewhere. I decided to trouble shoot by changing the array statement back to an if statement, and just like that, my powerups were back. That wasn’t good enough though. My stubborn mentality said, nope, let’s get that array working again. As I added them back one at a time, I noticed that I needed to reassign the powerup prefabs in my inspector, and that resolved the issue. I suppose not all fixes are in the code. I assume at some point my inspector became disjointed from the assigned prefab, so I was getting an empty object error attached to the array.
I’m pretty excited to be into the framework section now, and have already made a small dent into that checklist. I absolutely need to dive deeper into understanding C#, as that is still my biggest hurdle, but forward motion seems to be steady and that is encouraging.
I think it’s also important to mention that even through the ups and downs involved with coding, I’m having fun.