New Feature — Thruster Cooldown

Objectives:

  • Activate thruster when the player presses LEFT SHIFT
  • Limit time of thruster activation
  • Cooldown before able to use thruster again
  • Provide feedback to the player using UI

In this article, I will demonstrate how I implemented a thruster cooldown system with on-screen feedback to let the player when they can activate the next one.

On-Screen Elements

In the first section, I will create feedback on the screen to let the player know when the thruster was activated and when the it can activated again by the use of a progress bar

Add to an existing UI Canvas (or one will be created), UI | Slider.

Position Slider where you would like on the screen.

Change the Transition to None. Navigation to None.

I am using a Red fill and have created a background in Photoshop that I will use.

Remove the Handle image from the Slider

Finally, I added a UI Image and dragged it over the left side of the Slider to indicate what the bar is for.

Thruster Behaviour

Create the Thruster script and attach it to the Slider which I had named ThrusterUI.

In the script, there are three variables to hold the reference to the slider, how fast the bar replenishes and is the thruster activated flag.

I have a Start method to set the maximum value for the thruster.

The Update method handles replenishing or reducing the bar

There are two public methods, one to activate the thruster and the other to return if the thruster is on or off.

In the Player Movement script:

  • thrusterMultiplier — increase the speed
  • isThrusterActive — is the thruster active
  • ThrusterBar — reference to the UI Slider ThrusterBar script

The Start method to store the reference to the ThrusterBar script

In the GetInput we now look out for when the LEFT SHIFT key is pressed and activates the thruster

In the Move method, we check if the thruster is active and add an additional if-else and if active then use the Thruster Modifier to affect the Move Speed.

Now when the player presses the LEFT SHIFT, the thrusters activated causing the moving speed of the player to increase by the thruster multiplier for a few seconds and is not available till the bar is full again.

If you enjoyed reading this article give me a Clap, also if you would like to see more, “Follow” me, so you may be notified of future releases. You may also send me a message if you need any further help.

--

--

--

A Data & Analytics Consultant who is expanding into developing experiences in XR, Enterprise and Gaming space using Unity www.jeannoelseneque.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

MAP Protocol Semi-Monthly Report #69 (Jun 1st — Jun 15th)

How to: Build a blog with Gatsby and Odoo

Windows 10 Terminal

VERSUS joins QUDO’s ecosystem

A love letter to Github’s tutorial

Using Graph Database when dealing with connected data

Building a Go Web App from Scratch to Deploying on Google Cloud | Part #4b — Containerizing our Go…

7 Facts About Remote Workers

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
Jean-Noel Seneque

Jean-Noel Seneque

A Data & Analytics Consultant who is expanding into developing experiences in XR, Enterprise and Gaming space using Unity www.jeannoelseneque.com

More from Medium

Unity : AI [Navmesh implementation (Part III)]

Working with Unity’s 2D Tilemaps

WebGL Optimization in Unity

Adding Post Processing to our Prototype