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:

--

--

--

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

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

Recommended from Medium

Appendix 05: Tooling With Engineering Clarity

Type Inference, strict typing and dynamic typing

Effective Java! Prefer Interfaces to Abstract Classes

25 Useful Python Snippets for Everyday Problems

useful python snippets for every day problem

Deploy Spring Boot + Angular app using Docker on Ubuntu(on ec2)

How do IBM & Slack work together

Neptune Mutual Monthly Report — March 2022

100DaysOfCode Review

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.

More from Medium

Tessellation in HDRP

Reflection Probes in Unity!

Time to Powerup!

Wall Jumping