2D Game Dev Journey — Day 25: Homing Missile
Welcome to 2D Game Dev Journey — Day 25: Homing Missile. Today I go over how I implemented the homing missile power-up which tracks and goes towards the nearest enemy.
Starting Point & Setup
Today we will be starting right where we left off in 2D Game Dev Journey — Day 24: New Enemy and Enemies Destroying Pick-ups.

To get set up for today, I went ahead and created the missile sprite we will be using for this power-up.

I also went ahead and added in the power-up collectible with its animations for the homing missile.

Homing Missle Implementation
Now if I am being honest, the implementation of this homing missile was a lot harder than I initially thought it’d be. This is for a variety of reasons, but one of the main reasons was making sure my rotation matched up, or at least looked close enough, to the forward direction the missile was traveling. After a few different tries and code implementations, I was able to get the result below:

Even with today’s challenges, there are a few things I am proud of. For one, I was able to get more comfortable with quaternions today as they were the means of getting my missile rotations correct.

I was also able to figure out how to make the missiles track different enemies unless there is only one enemy currently spawned (which can be seen in the GIF).
Conclusion
Thanks for checking in and reading today’s article. Tomorrow I will begin balancing out the spawning, as well as creating a wave system. If I have made any mistakes, please let me know so I can correct them for future readers. If you would like a more in-depth tutorial about anything I went over today, let me know and I will take the time to write something up.