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

Data structures

Prefer Builders over DSLs

How to choose a programming language to learn

Power BI Challenge 8 — Power BI Insights From Jira Reports

Growing as a software engineer

Checking for vulnerabilities in Python with Safety

iOS Dev Course: UI Building

Mid-April Product Updates

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

How to Install the Universal Render Pipeline

Tessellation in HDRP

Adding a ram attack to our boss

Understanding the Body Settings in Cinemachine Virtual Cameras