2D Galaxy Shooter — Implementing a Thruster Speed Boost

Marcus Cohee
3 min readSep 4, 2021

Hello all!

Today, I will go over how to make a small speed boost using the Shift key! But when you deplete the thrusters, you will have to let them recharge before you can use them again!

Thruster Behavior

This is pretty similar to the Speed Boost powerup I made earlier, I did do some bug fixes to that though.

  1. Open the Player script.
  2. Create variables:
    [SerializeField] private float _thrusterLimit = 100;
    [SerializeField] private bool _isThrusterCoolingDown = false;
  3. Head down to CalculateMovement().

4. Then add an IEnumerator cool down system.

5. Test it out! Watch the Thruster Limit in the inspector and see if it recharges correctly.

Adding the Thruster Gauge

Now, let’s add an UI Element to show the Player’s Thruster Limit.

  1. Select your Canva.
  2. Add an Image to the Canvas, making it a child.
  3. Rename the Image, “Thruster Gauge”.
  4. Select the Rect tool at the top left of the Scene view or hit “T”.
  5. Position and size it how you want it.
  6. Anchor it to the closest corner.

7. See that Doughnut in the red box, drag it to the side like I have mine.

  • This makes it when we change the scale, it will extend from there instead of the center

Thruster Gauge Behavior

Now the rest is in the UIManager script. This is interesting because as the Thruster Limit is used or recharged, you have immediate feedback on screen!

  1. Open the UIManager script.
  2. Create Variable:
    [SerializeField] private RectTransform _thrusterScalingBar;

3. Make a new public method:

This is a method I call up in the Player script.

4. Test it out! Look at the players inspector and watch the feedback.

This has been making a thruster feature and displaying it in the UI! Next, I will shake the camera when the Player is damaged!

Thank you for your time!

--

--

Marcus Cohee

I am starting Unity and learning the ropes as I go! Let’s take this journey together!