Phase II

I made it! One more phase before I can move on to the cinematography courses. Last time I checked in, I was still having a few issues that need to be sorted, and I am pleased to report that they have been fixed. Now, there are still some old bugs I will need to deal with soon, like enemy explosions occasionally firing lasers at the player, but I have checked my boxes to move forward.

I was able to get my missile powerup center to animate properly after parenting it to the main body of the powerup. I am using two sprites because I want to animate them both independently, while having the function together. While the main glowing part of the animation is working now, the clockwise spinning of the other part, while keeping the center stationary, while dropping them both down the screen as a single powerup unit, is proving to be a little more complex that I anticipated after running through the motions in my head. Being that my powerup otherwise works fine and animates properly, I will move on being it’s not something that needs to be done for my checklist. It’s just me wanting to fulfill the original idea I had, and showing myself that I can make it happen.

I was able to finally get my thrusters sorted out! I was thinking too much about the values in the inspector concerning the slider used to represent thruster life. I saw that you can access them through a minValue or maxValue command, but I could not figure out how to access it for the file of me. As much as a still do want to know what I was doing wrong, i also needed to move forward any way I could. What ended up working was to go ahead and define values for _maxThrust and _minThrust in my player script. I also added a value for _currentThrust. I took some liberties to not only clean up some of my code by creating a few varieties of thrust methods, but I also found out that you can call a method from another method! After some experimenting with this, I discovered that order of operations is important, and I can’t just go dropping methods in other methods and always expecting them to work properly. Here is how I made it work this time around.

I made methods for Thrusters UI(), where I put all of my code for getting my values to update in real time with the UI slider. This is also where I finally implemented a max and min value for my slider my limiting the thrust with some if statements.

if (_currentThrust > = _maxThrust)
{_currentThrust = _maxThrust)

I made a Thrusters() method, which sets a max speed value for my ship, keeping it from going to warp speed and breaking the game, as well as my functions for speeding up and slowing down when shift is pressed and released. This also has the last piece of the puzzle, telling my ship that every time I hit _minThrust, _currentSpeed = _defaultSpeed. That is exactly was I was going for. I want to be able to use the thrusters even if only there is a little gas in the tank, but as a consequence, you ALWAYS reset to normal speed as soon as the tank is empty.

Last I added yet another method called ChangeThrust(float _thrust), basically to interact live with my Thrust Bar script. That was more methods for thrusting than I ever imagined creating, but I am happy for the organization. Being my Thrusters() method is related to my ships movement and speed, I tried calling it from my CalculateMovement() method and was pleasantly surprised to see it worked!

Regarding my missiles….I had some issues finding new targets after the original had died, and they needed some direction for how to act with no enemies present. After some research and implementation, I had everything working exactly the way I wanted in the game, only I would get a RED error whenever I fired a missile and no target was present. I was told that these errors are game breaking and need to get sorted even though things are otherwise “working”. This proved to be a longer task than I anticipated. Long story short, I got some help from a team member Troy, via his amazing blog here on medium tackling the same issue. (Thanks Troy!!). I had trouble calling “FindGameObjectWithTag”. The issue is that I was targeting the enemy transform, so I HAD to add .transform after “Tag” for VS to be happy, but it still didn’t work. I eventually moved over from targeting the transform to targeting the enemy GameObject, just as Troy had his setup, and that fixed my errors. The last part was telling the missile to move up, if there were no enemies present. Now it works great. No errors and the missiles just cruise like a laser until an enemy presents itself, then they seek and destroy.

Many thanks for my helpful team members, our leadership and of course this amazing opportunity to learn and develop new skills in trying economic times. Mahalo!!!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store