# GameMaker: Homing missiles

(mouseover/click to play GIF)

This is a post about implementing homing missiles in GameMaker.

A homing missile is a type of missile that can alter its direction mid-flight to hit a (generally) moving target.

# GameMaker: Angular motion

It's like drifting. On a spaceship. In space.

This is an example of managing angular motion in GameMaker.
In turn, that means having angular speed with acceleration, friction, and limitation.
Such can be particularly useful for simulating a more 'smooth' rotation behaviour, when object will not start or stop rotating instantly.
If combined with relatively properly written code for linear motion, this can grant pretty nice behaviour for space games.
Also there's a "trail" effect added, originally just to demonstrate how it works.
Everything is pretty nice and simple.

# GameMaker: Turret rotation (with limits)

It's actually pretty hard to describe what this does without an image.

This intermediate example demonstrates, how to create turrets with limited rotation range, and fixed rotation speed.
Basic use for this would be to create units that cannot shoot backwards without rotating towards angle entirely.

# GameMaker: Orbiting

Interactive demo. Mouseover to activate, drag planets around.

This is an example of making an instance orbit around other instance in GameMaker.

In contrast to other similar examples (and commonly given advice of the kind), it allows to define orbiting speed in a common way (pixels/frame instead of degrees/frame).

This is accomplished by calculating the distance to orbit' center (from current position), calculating the orbit' length, and thus converting pixel speed to degree speed.

New position is then calculated and instance' speed is adjusted for it to reach it the next frame.
This allows to use direction in collision calculations as per usual.

Overall, the code is simple enough but documented regardless.

Code follows,