Creating an Enemy with a Shield in Unity

Extra layer of protection for the enemy

Objective: create a new enemy type with a shield, the shield can take 1 hit.

First thing was to drop the shield sprite and change the color and the size to make it different from the player shield.

Then I added the collider and rigidbody components to detect the collision with the shield.

Next step was to duplicate the enemy prefab and create a new one called enemy_shield and add the new shield as a child of the new prefab.

After that I created a new script called enemy shield and added it to the shield shield object.

In the Enemy Shield script I added the OnCollisionEnter function to detect the collision between the shield with the player and the laser and destroy the shield.

And that’s it!!! Now we have a new enemy type with a shield.

A Software Engineer passionate about game dev and interactive products with Unity. I consider video games to be the artistic expression of programming.