Day 21: Shield Health

The shield power up will now be able to absorb 3 shots or 3 ships before expiring. The shield shrinks whenever the shield is hit to give the player a visual queue on their shield health (Homage to Gradius).


A new variable named shield health was added to be able to set the amount of health the shield can have (max 3).

Our shield game object reference will also be used to scale the shield down by reassigning its transform.local scale

Modifications made in ShieldAcive() and Damage() method to revolve around the use of our new shield health integer.

ShieldActive() Method

This method will return the scale of the shield game object back to its original scale and reassign shield health to 3. It will also set the game object active to display visuals. This method is redundant when initially called, but its useful afterwards.

Damage method shrinks the game object and decrements the shield health integer. I need to return the original values to the shield game object so that the shield will work properly.

Damage() Method

The damage method is only called when the player has collided with the enemy’s laser or the enemy themselves.

The method will first check if shield health is greater than 1. If true, then shield health and scale will decrement.

use the shield game object reference to adjust the scale of the shield

added a int variable that will be decremented when the player is hit. The scale of the shield will shrink and shield health will decrement. The method execution will be interrupted by a break. This will occur until shield health is decremented lower than 1.

Once shield health is lower than 1, the game object is disabled and method execution will bypass our initial shield if statement.


Thanks for tuning in, till next time





Unity Developer Based out of California

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

Recommended from Medium

PandaDoc API Enhancements: Jan & Feb Edition

Announcing the Incentivized Test flight Rewards

The Case for Reactive Architectures — Dropping the Client-server Paradigm


Connect to a private MySQL Database Service Instance via PublicIP

Flatiron Phase 2 — React

My coding environment setup from scratch on Ubuntu 18.04

Azure Sentinel Notifications

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
Vixian Phimmasone

Vixian Phimmasone

Unity Developer Based out of California

More from Medium

Loading Scenes in Unity

Advantages and Disadvantages of Unity Game Development

Occluders in games..!

Why You Don’t Need to Live in a Big City to work in Game Audio (And Why You Do)