From Photographer to Video Game Creator — Day 10
Well, today I hit my first big road block…
I began working more with the building process within Unity and nothing seemed to be working. I double and triple checked all of my files and everything seemed to be in place. I literally was out of ideas.
Somewhere, something was wrong. I jumped back into Google and posted my error on a couple threads and FINALLY received some help! The problem turned out to be a simple issue dealing with where my project was being stored. After moving a few files into the correct locations everything was back on track. My project was building and running smoothly!
Since I was already in the mindset of fixing things, I decided to revisit a few minor bugs that were popping up in my game. The first was dealing with my Player damage. I coded the damage to appear randomly on the left or right wing but sometimes the damage was appearing on the same wing twice. I needed a solution that would start the damage animation on a random wing, and then damage the other wing that had no damage. This took a bit a planning but I found a solution by using private bools. A bool is a true or false that can act as a switch for components, allowing the code to turn them on or off. I created a bool statement for the left wing and one for the right wing. The damage animation would still be assigned randomly but then it would go through a short checklist within the code. Long story short, if the right wing was damaged first, the “_rightDamage” statement would be turned to “true” telling the code to then damage the left wing upon taking the next hit.
The next bug was with my Enemy object. When the Enemy is destroyed by my Player, the enemy was set to disappear but stay active for another couple of seconds to allow the explosion animation to play. Even though the Enemies were not visible in the game view, the Player could still run into them and lose a life. I needed to turn off the trigger collision which was within the box collider component. This code was quick and easy since I was already dealing with the Enemy script. I simply grabbed the component with the “GetComponent” command and set the Box Collider to become false after the collision. Then, after 2.5 seconds and the animation has finished playing, the Enemy object would be destroyed.
Today started rough, and then got a little rougher, but I did finish on a high note and solved a couple key bugs in my game! So I was stoked on that. I also attended our Friday workshop where we continued with learning more about animations and how to manipulate them to fit better with our objects. We created a hovering ship that also had dust and smoke moving around it. Super neat stuff and excited to try it out within my own game!
See you after the weekend!