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

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.




Passionate Unity Game Developer

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

Recommended from Medium

All you wanted to know about CORS

Virtual environment for Python in Visual Studio Code?

Pointers in Depth

How to Resolve QuickBooks Error Code 6147, 0?

The New Twitch API

The day the IoT died

Modern C++ in Advent of Code: Day17

Spreadsheets vs Databases (What’s the Difference)?

DashboardFox - Self-Service BI for Spreadsheets and Databases

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
Chris Hilton

Chris Hilton

Passionate Unity Game Developer

More from Medium

Transposer Virtual Camera Explained in Unity’s Cinemachine

IK Weapon System in Unity

Switch Statements To The Rescue!

Creating a UI Shield Strength indicator