New Enemy Type with Shield
How to create shielded enemies

To create this behavior we create a new variation of the Enemy Damage script. We created a child game object shield that is set active and when the enemy gets hit it doesn’t take damage and the shield is deactivated. We use the following code:
private void OnTriggerEnter2D(Collider2D other)
{
//Debug.Log(other);
if (_isShieldActive == true)
{
_shield.SetActive(false);
_isShieldActive = false;
if (other.tag == "Player")
{
//dmg player
_player.Damage();
}
else if (other.tag == "Laser")
{
//destroy laser
Destroy(other.gameObject);
}
}
else {
//if other is player
if (other.tag == "Player")
{
//dmg player
_player.Damage();
//add 10 to score
_player.AddScore(10);
//destroy us
StartCoroutine(EnemyDeath());
}
//if other is laser
else if (other.tag == "Laser")
{
//destroy laser
Destroy(other.gameObject);
//add score
_player.AddScore(20);
//destroy us
StartCoroutine(EnemyDeath());
}
}
}