“Funslingers” Devblog #13 | Making A Shields Powerup With Switch Statements in Unity
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!