Finally here is a video that shows a large number of missiles chasing another missile:
To create a guided missile like this, you have to do a few things:
Have a target, that is updated every frame with its current position
(Optional) set some fixed waypoints on the way to the target to alter the flight path, this creates the overhead strike you see in the video, and is one way to improve accuracy
Create a “steer point” that will guide your missile towards the next waypoint/target, but corrects for velocity of the chaser and the chased
Turn the body of the missile until it is facing the steer point.
When we are happy with the facing of the body, we accelerate it.
If you want the missile to explode, you can check distance from target, or use Box2D’s contact listener
Setting the targeting and updated it’s Vector2 position should be easy enough, so I won’t explain it here. Let’s skip to step 3.
Assuming we have a target, let’s face the target
let’s correct for velocities:
Now let’s seek the waypoint: And that’s about it. Here is the code for constraining the angle to 180 and -180 degrees: Now you need to implement acceleration and contact/explosion handling on your own.