2D Certification: Homing Projectile

In the last article, I added an enemy type that can avoid player fire. Today, I’m going to be continuing the second, and final, phase of the GameDevHQ 2D Game Development Certification track. In this article, I’ll be adding a homing projectile! The requirement reads as follows:


  • Create a homing projectile that seeks the closest target. * Include Rare powerup to activate

The homing projectile requirement required quite a few steps that have been covered in previous articles. I started by creating a new powerup collectible, animating it, adding it to the spawner, and adding an enum value to be picked up in the Player class. these were much the same as when I added the triple shot, the spread, shot and other powerup effects. I then added another set of variables in the Player class that were similar to those for the triple shot for tracking whether or not the triple shot was active. I also included some changes to the code that selected which projectile to instantiate based on which shot was active.

Next I focused on creating the new projectile prefab. I created a new prefab with new graphics and attached a new script for seeking enemies. I knew that I had created similar functionality for seeking an object when I created the aggressive enemies that would ram a play if they got close enough, so I went back to look at that code and decided to duplicate a lot of the functionality. In the future I may come back to refactor these classes to be more generic and handle this seeking behavior for more objects but for this exercise I decided to create the functionality again and change the type of the objects involved.

This strategy worked well and I now had a homing missile! In the future I definitely want to refactor this seeking functionality to be more generic though and have it work with any two objects passed in for one to be able to seek the other.

Next Time!

In this article, I added a homing projectile. Next time, in the final article of phase II, I'll be adding Boss AI! If you enjoyed this article, or want to come along with me as I progress on my journey, follow me at gamedevchris.medium.com.



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
Christopher West

Christopher West


Unity Game Developer, Software Engineer, Gamer, Musician, and Father. Christopher is a creative that enjoys a challenge and loves coding.