Day 45- Making 2D Space Shooter Game
Objective: Making enemy spawn with shield which allows them to take one more damage
First we need to create a variable to store the shield and a bool variable to detect if the enemy has shield during spawn or not.
Now we don’t want this enemy to always have shield, instead we want the enemy to have 10% chance of spawning with a shield
We take the random number and if it is 5 then the enemy will have a shield during spawn. Note to write this code in Start.
Lastly create a condition to ignore one hit from player or laser and set the shield to inactive during that process.
Now the enemy can take one extra damage which will set the shield as inactive and the next time the enemy will get destroyed.