Zac Bogner

Jul 6, 2021

3 min read

Creating Enemy Shields; One feature, multiple answers

There‘s not only one solution to a problem to solve. There are many ways to solve problems.

Revisiting the 2D Space Shooter project. I was going through some tasks, and decided to work on implementing Enemy Shields.

Objective: Creating an Enemy Shield behavior in a creative and unique way to make it work through trial and error and a lot of testing.

To begin this process, I duplicated my Player Shield GameObject.

We will go into the Enemy Prefab and make our new enemy shield a child of the parent Enemy object.

Implementing the Enemy Shield behavior.

The Enemy Shield needs to have its own script attached.

Let’s break down what we’d need to create the Enemy Shield logic.

Now lets see how I made this particular system work.

I was able to approach this scenario creatively, and in a way I did not know after testing that this was one way to implement this feature.

Additionally, we need to see if the other gameObject’s tag will be detected by a PlayerProjectile.

If we did that successfully, we need to get inheritance of the PlayerProjectile script.

From here we get the Rigidbody2D component and go into the properties:

Using the discrete property, it worked perfectly for my implementation; And I’m sure there are many other ways to accomplish this same feature.