Unity: Activating/deactivating the shield visualizer
Objective: We need to make it so when we activate the shield power up the visualizer shows up so we know it’s active and when we take a hit it goes away to show that it isn’t active anymore.
First we need to add our shield visualizer into the hierarchy and you should make it the child of the player. Once, it is the child of the player game object you want to deactivate it by pressing the check mark beside the name in the inspector.
After you’ve got everything set up we want to go into our player script and add a new game object variable for the shield visualizer. Then go down to your shield active method and you will want to add the shield visualizer variable you just made and set it as active.
Next you’ll want to go to your if statement that handles your shield power up in your damage method and do the same but in the brackets of the set active you’ll want to write false to set the visualizer as inactive.
Lastly, you should test to make sure the visualizer shows up when you get the shield power up and it disappears when you take a hit from an enemy.