Phase 1 — Shield Strength

Nicholas Lim
Jun 8, 2021

The Player’s shield should last for three hits and have an indicator that the shield is weakening. I’m going to make it more transparent the more hits it takes by lowering the alpha each hit.

The Alpha value being changed, under the Sprite Renderer’s Color settings

In the Player script, provide a reference to the shield’s Sprite Renderer.

Player script

When the Player is damaged when shields are active, decrement shields left.

  • At two shields remaining, lower the alpha to 0.7f
  • At one shield remaining, lower the alpha to 0.4f
  • When no shields remain, deactivate the shield effect and deactivate the visual

Each time the Player collects a Shield powerup, reset the Color to have full alpha of 1f, and set shields remaining to three.

--

--