Implementing a New Enemy Type in my Game

Michael Lam
3 min readSep 21, 2023

--

Today, I created a new type of enemy that will have move and shoot differently than my original enemy. I overthought how to do this at first so it took much longer than it needed to be.

I first created both the new enemy and the laser that they will fire and add them to my prefabs.

In the enemy script, I added a new variable for the enemyID to differentiate between the new enemy and the original one.

I added the ID to a new specific movement separate from the original movement.

As well as adjusted the new enemy’s laser and fire rate.

In the Spawn Manager Script, I changed the enemy prefab variable to be an array and added the new enemy to that array.

Then, where I’m spawning my enemies, I added a random number generator from 0 to 1 for the enemy and instantiated the enemy prefab based on that number. This way, the enemies spawn will be randomized.

With all of this, my new enemy is working properly and is now a new threat for my players to try and destroy!!

--

--