Homing missile prototype

I started off the day with creating and integrating a new Rare Powerup script which spawns on a much longer time interval. As I mentioned in my last post, the RarePowerup script is exactly like my original Powerup script with the only difference being the time interval of when powerups are spawned. I’m guessing this is quite redundant and that there is a more efficient way to handle this but this way works for now.

Once I had the new script attached to the rare powerups (homing missile and health), I made sure all powerups were spawning correctly and then I moved on to creating the actual homing missile.

My new homing missile sprite.

I found this png file of a purple laser cloud that I converted to my homing missile sprite by adding a 2D circle collider and a rigid body 2D. I also created a script dedicated solely to my homing missile and attached it to the new sprite.

As a first step, I made my homing missile function exactly as a laser by shooting directly up in a straight line. After I got this working, I modified the missile movement by using the Vector2.MoveTowards( ) method and set it up so it moves towards any game object with a tag of “Enemy”.

Homing missile — first prototype

As you can see here, I still have some major bugs to work out. The homing missiles continue to home in on where the enemy last was, even after the enemy disappears. The enemies were modified when attaching the explosions and were set to self destruct only after the explosion animation was fully played (so a couple seconds after the enemy is hit). Also, if there are no enemies, the homing missiles seem to move to random places on the screen and sit there until an unfortunate enemy runs into them. This is not how I intended them to work so I’m counting this as an important first step and will continue to modify.



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