Layered Defense: Adding Enemy Shields (Game Dev Day 45)
Objective: Give the standard enemies a chance to spawn with a shield that blocks 1 hit.
This is a fairly simple implementation as the shield logic already exists for the player.
I start by adding a new bool as well as a gameobject. The gameobject will be linked to the shield graphic.
I added a some logic in void Start to give the ships a roughly 50% chance to spawn with a shield.
I also set the _shield.SetActive to be linked to the _isShieldOn Variable. This means if one turns on, the other will as well.
With that, the shield will show up, but it has no functionality. Some logic has to be placed in the OnTriggerEnter section of the script.
Simply put the projectile is broken (always), and then if the shield was up, it turns the shield off. If there is no shield up when the next projectile hits, it does the default destroy enemy logic.