“Funslingers” Devblog #28 | Creating A Health Powerup in Unity

Ethan Bristowe
Everdevs Community
Published in
2 min readSep 10, 2021

Hey Devs!

Now that we have a great way to replenish ammo in our game, I think it’s time we have a way to replenish health!

We’ll kick this feature off by creating our Health Powerup Prefab, plugging in our Powerup Script and adding it to our SpawnManager, just like all our other powerups!

And now we just create the powerup behavior in our Player script. First thing is when the Player collect the powerup.

We don’t let our lives variable get any higher than 3, and then add 1 and call a LifeCounter() method. This is a modified LoseLife() method that will be used to both add and subtract life from the player depending on the passed in bool!

So if the Heal bool is false, which we would call in the LoseLife() method:

Then we would subtract a life and activate all the effects with it, inside the switch statement.

If the Heal bool is true, then we would start a similar switch statement that takes the current _lives variable, and re-activate the lost life heart counter and stop the players bleeding effect as well!

All these powerups so far have been very simple and fast to implement, and that’s all thanks to our modular and efficient scripts! However, what’s programming without a little challenge? In the next devblog, we are gonna tackle a completely new weapon powerup with a very complicated feature!

--

--

Ethan Bristowe
Everdevs Community

Passionate self taught game developer excited to learn and share everything I can about game development!