Adding Shield Strength

Another feature to add to the player is lives to the shield through visually showing it by colour so it looks like the shield takes damage. We start by duplicating the shield within the hierarchy:

We then make these shields visually different within the inspector by changing colour or size, whatever suits the look you are going for. I went for colour.

Shields 1 Colour
Shields 2 Colour

Within the Player script you will need to add some variables. One of them will be an array like so:


the array can be assigned within the inspector once saved like so:

Player shield array within inspector

to activate the shield through the array we use this method:

which increments the shield after collecting the power up and on the shield visual based on the level it is at. It then reverts back to the damage player method: