Shield Strength

Let’s update our game to give the shields power-up 3 hits before loosing shields, and lets show the player what level the shields are on by changing the colors of the shield.

We need a _shiledLevel integer to keep track of what level we’re on and we’ll start with it at level 3. And, lets add that to ShieldsActive() so that it resets on every shields power-up we collect. While we’re at it, lets reset the color. How to reset the color? We’ll need to reach into the _shieldVisualizer GameObject (serialized) and grab the material property of the SpriteRenderer component like this:

And then we can use SetColor() in a case statement to control the color in the Damage() function:

And now for a test drive:



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
Richard Morgan

Richard Morgan


Unity and Flutter developer interested in creating mixed-reality applications.