Phase I: Player controlled Thrusters

All of the basic functionality for the game is completed. Now it’s time to start adding additional features to the game.

The first feature to be added is a Speed Boost Thruster when the Player holds the Left-Shift key down. It should only add the boost when the key is held down and go back to normal speed when the key is released.

I’ll start by making some new variables. In addition to the _speed variable that was already being used, I want a variable for the base speed and thruster speed. Both will be serialized so they can be adjusted in the Inspector.

Variables for Base Speed and Thruster Speed.

Next, I created a method called ThrusterControl and placed it in between the PlayerMovement and LaserControl methods. The method uses Input.GetKey to check if the key is held down, and if so, it applies the Thruster Speed; otherwise, it applies the base speed.

Thruster Control method for checking and applying speed boost when Left-Shift is held down.

Now, below you can see the ship movement speed boost when I press the Left-Shift key and return to normal when it is released.

There are many ways to accomplish this functionality. And this is one of the easiest to implement. As we add additional features to the game, it may become necessary to revisit this and make further adjustments. But that is the nature of game development and software development in general.

Hopefully, you found this informative and helpful.

As always, until next time, I wish you the best of luck on your coding journey.



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