Let’s Add Some New Enemy Types to our 2D Galaxy Shooter in Unity!

Chris Hilton
3 min readSep 6, 2021

--

Objective: To create 2 new enemy types that are going to have different movement, weapons and avoidance features.

Firstly I have gone ahead and grabbed some 3D spaceship game objects to take a top down photo of to edit and save as a PNG file in Photoshop, exporting them out onto a sprite sheet. I now have 3 new models for 3 different types of enemies. The first enemies features that I have previously created will remain as is, but these 2 new ones are going to have some pretty cool features!

Enemy 1-Original

Enemy 1 (Original Enemy)

Enemy 2-Teleport

This enemy is going to have new angular movement with a different spawn and end position every time. It will also have a random chance to spawn with a shield that is going to take 2 hits from the player’s lasers. Finally, it will have an avoid shot feature that uses raycasting to detect a player’s laser in front of it and it will teleport to another part of the screen randomly. This will have a cooldown so that the player has a chance to destroy it!

Enemy 2 (Teleport Enemy)

Enemy 3-Laser

This enemy is also going to contain a new movement which is going to be sideways across the screen. If it reaches the bounds of the screen it will automatically appear on the opposite side. It will also have a random boost feature that will be used on a random timer. Finally it is going to shoot a nasty laser beam like the player!

Enemy 3 (Laser Enemy)

Components List

For all 3 of our enemies we are going to need the following components:

  1. Sprite Renderer — with Sorting Layer set to ‘Foreground’ and Order in Layer is ‘1’.
  2. Box Collider 2D — with Is Triggerticked’. Box Collider set up appropriately around the sprite image.
  3. Rigidbody 2D — Body Type set to ‘Kinematic’, Collision Detection set to ‘Continous’ and the Sleeping Mode to ‘Start Awake’.
  4. Animator — Which contains the explosion animation.
  5. AudioSource — Which contains the ‘Explosion Sound’ in the AudioClip box.
  6. Enemy Scripts— Which is going to run the different movements, weapons and features.

--

--