My journey becoming a Unity game developer: Phase-44

Rhett Haynes
2 min readAug 8, 2021

--

Objective: Changing the Shields colors to represent the amount of lives the player has.

In the Player script, go to the ShieldsActive() method where we will set up 3 IF conditions using the SWITCH() statement. The parameter we will pass in is the _lives variable representing the amount of lives the player has at the moment. Then use the CASE number to represent each life the player has left and call on the shieldVisualizer game object to get the SpriteRenderer component. Inside the SpriteRenderer, we want to get the Material and access the Color property. Once that’s done, change each color to show each amount of lives remaining which was done as follows: 3 = white, 2 = blue, 1 = red.

Switch() statement used to change the color of the shield according to how many lives remain.
Player shield is white representing 3 lives remaining.
Player shield is blue representing 2 lives remaining.
Player shield is red representing 1 life remaining.

I will add some extra features to the shields in the future, but next will be limiting the player to 15 shots.

--

--

Rhett Haynes
Rhett Haynes

Written by Rhett Haynes

Learning to become a Unity game developer.

No responses yet