Adding another type of enemy to my space shooter

It’s time to add another unique type of enemy to my space shooter. You know what everybody loves? Tiny versions of normally-sized things. They’re just so cute. Using that logic, I made some tiny enemies! This is a new enemy type that spawns with two smaller enemies on each side of it that fire rapidly. In testing, these have proven to be very dangerous because it’s very hard for the player to get in and get a shot on the main enemy without taking damage from the little ones.

FIRST! I created a new prefab for the tiny enemy as a duplicate of the normal enemy prefab and scaled it down. I also removed the enemy script because I’m adding a separate script for the tiny enemies. Once the tiny enemy was created, I added them as children inside the normal enemy prefab and placed them appropriately.

Now, they need some logic to fire. I used the same firing logic that exists in the enemy script, just made the fire rate quite a bit faster. It also instantiates each laser as a child of the tiny enemy, and scales them up a bit so they’re easier to see on-screen. I also added some logic that will destroy the tiny enemy if it gets hit with a player laser. That’s it! I also added another case to the enemy script code that decides the enemy’s type to enable the two tiny enemies.