New Feature — Health Collectible

Objective: Give the player an extra life when they collect a health powerup and update the on-screen UI

Creating new power-ups is super easy with the way we created this modular system. We are going to follow the exact steps we did in the last article for the Ammo Power-up.

Create Health Power up Prefab

Make a copy (duplicate) of the Ammo power up by selecting it and pressing CTRL + D

Let’s add the Health to the Power type enum

Click on the Health Power up and choose the new Health Power-Up type

Next, we will code in the behaviour of what happens when the player touches the power-up and that is it is to add 1 life to the player by calling the Heal method in the Player script.

In the Player script, the Heal method adds one to the player lives if the lives are under three. It then calls a helper method, UpdateLiveUI to update the on-screen elements.

Refactoring has occurred to ensure showing the ship's damage works from both directions, adding damage, and removing the damage.

Let’s not forget to add this new power-up to the SpawnManager.

Now let’s play the game. In this example, the player gets hit by two lasers and picks up the power-up that you can see gives them an extra life, and removes one of the wing's damage.

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

Understand setState() and initState() Method — Flutter

Creating tags in flutter!

How to Create Spinner — android

HUAWEI Scene Kit Puts AR Placement Apps at Your Fingertips

Playing with elevation in Android 🥧 (part 1)

Switch button kotlin android

Install Zoom Video Meeting on Xiaomi Mi Box

Unit Tests and Concurrency

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

VR Development — Day#4

Orbital Transposer Virtual Camera Explained in Unity’s Cinemachine

Adding Audio to our Prototype

Unity : Cinemachine and Timeline (Part II)