Creating a Health Powerup

Tyler Napier
Mar 26, 2023

--

To create our health powerup the first thing we want to do is drag our powerup sprite into our hierarchy. Then we’ll add a rigidbody, collider, and attach our Powerup script.

Next, we’re going to go into our Player script and create a method for the powerup. This method is basically going to increase our lives variable and our lives image if our lives are less than three.

Health Powerup method

Then, we’ll want to make sure that the damage animations stop playing when we collect the powerup.

Now, we’re going to go over to our Powerup script and add our method to our modular powerup system.

Powerup script

Make sure to add the powerup prefab to the SpawnManager inspector. Then add the powerup ID to the prefab.

Now our player will recover a life whenever it collects a health powerup.

--

--