GameMaker: Homing missiles

Homing missiles example for GameMaker

Do you like homing missiles? Of course you do!
Well, you may actually not, but for multiple genres of games these can add that bit of needed difficulty.
If you don't know how these work, here's an animated preview -

Homing missiles example for GameMaker

A homing missile is a type of missile that can alter its direction mid-flight to hit a (normally) moving target. You could probably read more about these on Wikipedia if you wanted.
In 2d games homing missile behaviour is mostly about gradually rotating from current angle to destination angle, which is demonstrated in this example.
Apart of actual missiles there's a similarly gradually rotating missile/rocket launcher, a wall drawing/erasing system (for sake of demonstration), and small "shards" appearing and bouncing around if a missile is to hit a wall instead of target.
Also there are some graphics in style of my earlier games.
Guess you could call this "pretty cool".

Download GMK

Update: deployment instructions:

  1. Add obj_launcher, obj_rocket, obj_shard to your source. obj_shard only needed for rocket explosions - if you're going to make your own, you can omit adding that and remove relevant code from "obj_rocket:collision with obj_wall" event).
  2. Change occurrences of obj_target in obj_rocket and obj_launcher to name if your desired target object (for most platformer games this is probably your player object). If you have multiple target objects in room, you may need to add target determination code (such as instance_nearest(x, y, obj_player)) there.
  3. Tweak parameters (third parameter in angle_rotate calls and speed modifiers in obj_rocket) to suit your game mechanics.

Related posts:

4 thoughts on “GameMaker: Homing missiles

  1. It seems that you have a simple mistake in your demo .gmk file. When a rocket collides with a block, it tries to create “obj_gib”, but in your object resource list, there is no “obj_gib”. Instead there is an object called “obj_shard”, and switching the code from trying to create an instance of “obj_gib” to “obj_shard” resulted in the error being fixed.

    Otherwise, good example! I believe some may find it useful.

    • Thanks, I’ve fixed that.
      Was a post-publication edit because term “gib” doesn’t quite apply to fragments of mechanical objects. Didn’t pay attention to whether I saved last change or not.

  2. I savor, lead to I discovered exactly what I was taking a look for.

    You’ve ended my 4 day long hunt! God Bless you man. Have a nice day.

Leave a Reply

Your email address will not be published. Required fields are marked *