Day 12 Phase 1 complete
Like I said yesterday, I couldn’t wait. I hopped up this morning and started to finish my framework for my phase 1.
So heading into today I had to put a limit cap on my lives value so when calling the method I stopped getting an error about my life being full.
Next step was to create a secondary fire function and have it drop rarely into the field of play.
I had some ideas when I peaked at this part of the phase yesterday.
I decided to make a new object that represented a beam of light that emits from the player and destroys any enemy that collided with it.
My next step was to create a game object that represents the beam.
After a quick google search I found a suitable .png and went to work.
To make things easier on me, I just made this object invisible and attached it to the player.
Next I just copied code from the shield method to make the new weapon visible. I tagged it “Particle Beam” and made the enemies dies when the collide with it.
Then shut off after 5 seconds.
To make a power up in game found an image that represents the beam power up and copied other power ups to make it droppable in game.
I did get stuck for a little bit because I forgot to set the ID of the power up to its own unique signature. So for a little bit I was head scratching because it was working but it gave the player ammo instead of turn on the Beam.
After I got things working the way I wanted them to. I moved on to make this particular drop a little more rare.
I created an algorithm that told the spawn manager that if it calls for this particular power-up it has a 33% to not drop and instead move on to a different drop.
Next, was to create a UI element that told the player how much Thruster they used and how much more of the thruster they can use.
Also create a cool down system for the Thruster.
After some thought, I decided to create another text message display that told the user “Thruster: X%”. Where x is the percentile number of how much Thruster is left.
In code I made another algorithm that told the Player class while the user is holding down the thruster button take a percentage off of the thruster number that is displayed. When the user is not holding the button add a fraction of a percentage every frame to represent a “charge time” for the thruster. I put this inside the Thruster method and made it so that the user cannot use the thruster if they are empty.
Looking back, I’m gonna have to tweak this logic a bit since it automatically charges when you let go of the button so in a sense you are never really out of thruster for very long.
Last thing for the day and for Phase 1 is shake the camera every time the player is damaged.
This one stumped me and took a long time to get.
I knew I needed to move the Transform of the camera. I also knew I needed a script to handle this. So I made a script and told the player if when they got damaged run this script too.
Finding the right lines of code to create this ability was a challenge that I could not do on my own. So I relied on the thoughts of others in blogs to find the answer.
The best one in my mind was create a loop the moves the camera for a duration of time and at a magnitude given by the developer.
I created it and then it did not work.
An hour of looking and modifying the script. I figured out that I had forgotten to start the method as a coroutine.
Finally, tested the behavior and Whalla!
Finished backing up my project and ready to start Phase2