Shield Strength

Matthew Bartosh
2 min readAug 31, 2022

Today my goal is to give Shields 3 hits, and add a UI element to track its health.

First I’m going to create three parent objects, each with the correct number of shield sprites in them, position them over my Player lives, then toggle their active state to false.

Then I’m going to create an array similar to the one I made for lives, but with game objects instead of images, I’m also going to leave an empty ‘No_Shields’ game object.

Now I’m going to create a public ShieldLife method within my UI Manager that just sets the current health ‘active’ and deactivates the previous one.

Lastly, I’m going to set _shieldStrength to 3 in my ShieldActive method, then modify my player damage method to check if my shield strength is over 0, in which case, I’m going to subtract 1 from it and update it when I take damage. Once it’s 0, then the shield will deactivate once more.

And here you can see an example of it in action!

That’s it for now!

--

--