2D Game Dev Journey — Day 23: Aggressive Enemy and Enemy Shields

Welcome to 2D Game Dev Journey — Day 23: Aggressive Enemy and Enemy Shields. Today I go over how I implemented an enemy that can “ram”, as well as a way for our player to attract nearby pick-ups.

Today we will be starting right where we left off in 2D Game Dev Journey — Day 22: Smart Enemy and Pick-Up Magnet.

To get set up for today, I went ahead and created the enemy that will be our aggressive enemy type.

Aggressive Enemy

As per usual, there are a few ways one can go about implementing this enemy, but I specifically took advantage of inheritance and polymorphism, as well as coroutines, to get this enemy properly working. By doing this, my code for this enemy ended up being only 44 lines.

Below is how the enemy looks in-game.

Honestly, I am pretty happy with this. The only change I would make is changing my raycast to a circle cast so that the enemy has a greater radius in which to detect the player. I will probably do this in the future.

Enemy Shields

When it comes to enemy shields, my goal is to allow any enemy to have a shield upon being spawned. These shields only take one hit, and I set the probability for an enemy to be spawned with one to 25% (at least for now). This is how they look in-game.


Thanks for checking in and reading today’s article. Tomorrow I will be creating the final enemy type, as well as a way for our enemies to destroy power-ups. If I have made any mistakes, please let me know so I can correct them for future readers. If you would like a more in-depth tutorial about anything I went over today, let me know and I will take the time to write something up.




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

Recommended from Medium

Do’s and Don’ts — Things I learned as a Full Stack Developer

The Secrets of Successful Open Source Business Models

Holonic Architecture — Hylo 3.0.0 Release Notes

You’re invited to the October virtual Haskell CoHack

How to find Spelling Corrections for a Word in Python with NLP

#freestockphoto (Monday 23rd 08AM)

Why Your Product Needs Analytics

Hydra system — Protect your Creativity

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
Gabe Gomez

Gabe Gomez

More from Medium

All Hail Pseudo Code

Setting up Camera Functionality

Bug Fix on Model Flip

2D Light Flicker in Unity