Everdevs Community
Published in

Everdevs Community

“Funslingers” Devblog #13 | Making A Shields Powerup With Switch Statements in Unity

Hey Devs!

The third and last powerup we are gonna make for this part of the devblog will actually be the easiest to implement, Shields! It will basically just act as a temporary extension of the player’s life, coding this will actually be easier done than said!
But first thing’s first! Let’s make our shield powerup prefab!

Sweet! Now let’s quickly add our Powerup Script and plug this prefab into our Spawn Manager to get this thing instantiating!

Now we got the easy stuff out of the way, let’s dive into this shield behavior!

First thing I want when the player collects the shield powerup is for the player to see that they are protected. So let’s create an aura around the player that will appear once the shield powerup is active!

One of the features I want for the shield powerup is to have a life counter of it’s own, so instead of the player just being invincible for a small amount of time. The shield will take damage for the player until it is broken. So to do this, I made three other shield aura effects that will be instantiated and uninstantiated as the shield’s life goes down. To get this feature working seamlessly, I reworked our LoseLife() method to account for shield life using a switch statement and a coroutine to make all of this possible!

And then all I have to do left is to give the player some shield health and call the Lose Life() method once the shield powerup is collected!

If all of this works according to plan we should have a really cool looking shield powerup!

I think our game is at a good point in terms of its gameplay, so I think the next few devblogs we should take a break by exploring making some UI for our game!

Game dev tutorials and news about Everdevs.

Recommended from Medium

Data Providers in TestNG

Be more Goldilocks: When and how to scale your startup engineering organisation

https://t.me/umad_launch_bot?start=r08973601900

Mind the Flex-gap

Umbraco CMS: A Beginner’s Guide

Recursion Tree Method to Solve Recurrences

GUI for Docker Container

Apache Kafka: Quick Start

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
Ethan Bristowe

Ethan Bristowe

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

More from Medium

Calculate Annual Income Tax Using Recursive Call

Windows MDT as code — Part 1

OAuth and Keycloak : Single Sign On

2.5D Platformer: Creating Collectibles