From Photographer to Video Game Creator — Day 8
STOKED for today! Coming from a photography and videography background, I was pumped up to start adding more visual effects to my game. Everything we have set up so far was proving to be extremely important and today was really going to test our script communication skills.
First on the list was to add an explosion to our enemy. This was very similar to the explosion we set up for our Player except this explosion had to communicate with both the Player script and the Laser Script. I also worked with some basic parameters within the animator tab to set an order for my explosion. This is so it only activates once the enemy has been destroyed and not before.
After the timing was set, it was important to remove the explosion from the hierarchy so that the Player wouldn’t be able to run into the object after the animation had finished. This was done by attaching a separate script to the explosion telling it to destroy itself after 3 seconds.
Now my Enemy explosion is completed and everything is working!
Time for the Player ship. I added a quick sprite animation to the Player and even key framed the scale which gave a cool pulsing effect to the thrusters!
Next up was to add some visual damage to the Player ship after it collides with an Enemy. I attached two more sprite images to the wings and added the animation. Originally, I coded the damage to appear on the right wing first and then the left wing, but I went a step further and coded the damage to appear randomly when the Player was hit. I achieved this by adding an array for Visual Damage and by using the “Random.Range” command.
Now we have some visual damage to the Player ship!
Final task for the day was creating a floating asteroid that would start the level when shot. This… required a bit of code. It seemed a little daunting but I took it one step at a time. I started easy by creating the Asteroid as an object and coding it to rotate slowly while floating in place. Then I had to allow it to communicate with the laser script so that when it was shot a few things would happen: First it had to start an explosion animation. Second was to destroy the Laser object. Third, the Asteroid had to communicate wit the Spawn Manager and tell the Enemies and Powerups to start spawning in. And Fourth, the Asteroid had to destroy itself.
One step at a time, it all came together and it actually worked! Haha, I was super surprised and STOKED that I was able to make something work! It’s a great feeling!
Ending the day feeling pretty good about my progress and ability to start solving some coding problems on my own. That’s all for now, see ya tomorrow!