Creating an Enemy with a Shield in Unity

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.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

.Net 6 Publish to Kafka topic (efficiently)

How to split an application into services

Quarkworks: Meet the Team Series — Fernando Salazar

Communication is hard (part 2)

How to Align Text in Excel Cells Using Java

Effective Inventory Management: your best defense against your next IT audit

The Campus DevRel Show 🔥 — Episode 3

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Rusben Guzman

Rusben Guzman

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

More from Medium

Simple Player Movement

Adding a player ammo indicator to the UI

Level Design in Unity Part 2: The Walls

Creating a HUD (part 2)