Creating Heat Seeking Missiles

When you play a game, combat can become repetitive unless there are aspects of it that feel diverse or unexpected. By incorporating different enemies that utilize different moves, weapons, and animations you can create all sorts of scenarios to challenge and entice your players.

For my Space Shooter game, I am incorporating an enemy that will fly in from the side stop, stop at a random location on the X-axis, fire between 2–4 heat-seeking missiles, and then fly off.

To make these missiles follow the player I will have to create a reference to the player object and get its transform. Then it’s mostly a matter of getting the missile object that this script is attached to rotate and follow the player.

Attach the script above to your missile object and make sure your player is tagged as “Player”. The missile will now follow the player and point in the player’s direction so long as it is on a 2D plane. Now it’s just a matter of setting up how you want your missiles instantiated. If you look at the GIF below you will see my enemy AI in all its glory!

--

--

--

Hi, my name is Adam Reed and I am a software engineer specializing in Unity and C# development. Feel free to scroll through and check out some of my work!

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

Recommended from Medium

My 10 Design Principles for 2020

G.D.W.N 001

Understanding the Elements and Principles of Design.

How to improve User Testing

Reddit: The Internet’s User-Driven Information Architecture

Into Integrity, Humility, and Righteousness — Monday Morning Inductions 2020

How to Usability Test a Government Service

GIF of 19 different prototypes of a tool

Long Lasting Solutions and Innovation in Design

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
Adam Reed

Adam Reed

Hi, my name is Adam Reed and I am a software engineer specializing in Unity and C# development. Feel free to scroll through and check out some of my work!

More from Medium

Making nice cameras in Unity with the Cinemachine plugin

Variables! — The building blocks of programming

Audio effects for Enemies

Cleaning up the Homing Missile code