Phase 1: Health Collectable

Objective: Create a Health collectable that will heal the player by giving back 1 life and update the UI visually.

I have previously written about creating a collectable and animating it. You can find those articles here: Creating PowerUp and here: Animating sprites

Once the collectable (powerUp) is created, I created a power-up called ship_repair and assigned powerup ID 4, we need to update the spawn manager. We need to expand the power up array and assign the Ship_Repair prefab.

In the Player script, we will need a method to add 1 life back and update the visual damage on the player as well as the UI element representing the player lives. I created a method called ShipRepair.

Ok, now it's on to the PowerUp script to call the ShipRepair method when the power-up is collected. I added a case to the switch statement for the power-up ID 4. The updated code is highlighted in green.

Let’s see this in action.

Happy Coding !!




Unity / C# Game developer

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

Recommended from Medium

Using Azure AD B2C to Authenticate Android App Users

This image shows the log in form that is rendered by Azure Active Directory B2C in an Android web view.


Guide to using Retrofit in MVVM Architecture with Data Binding (Hilt) & RxJava — Kotlin

Firebase Phone Authentication || Android example

Whats new in Jetpack 2021 Google I/O 2021

Drag and Drop using Draggable and DragTarget in Flutter

Run Multiple Android Studio Versions On A Single Machine

Phase 2: Enemies Avoiding the Laser

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
Bill Rislov

Bill Rislov

Unity / C# Game developer

More from Medium

New Input System and UI

Take Photo with Phone in Unity

Building A Stealth Game — Helping Your Guards “See”