# Avoiding orbiting in pursuit steering behavior

I have a missile that does pursuit behavior to track (and try and impact) its (stationary) target.

It works fine as long as you are not strafing when you launch the missile. If you are strafing, the missile tends to orbit its target.

I fixed this by accelerating tangentially to the target first, killing the tangential component of the velocity first, then beelining for the target.

So I accelerate in -vT until vT is nearly 0. Then accelerate in the direction of vN.

While that works, I'm looking for a more elegant solution where the missile is able to impact the target without explicitly killing the tangential component first.

• I don't think you can get a satisfying answer without explaining what your steering algorithm is. I'm pretty sure the problem lies in your heuristics there. – sam hocevar Dec 17 '12 at 12:45
• Actually, this was the answer I used – bobobobo Dec 17 '12 at 17:00
• possible duplicate of How to prevent homing entities from orbiting their targets – Trevor Powell Jan 14 '13 at 5:46

It looks like the problem is that the missile is simply pointing itself at the target without regard for it's current velocity. Assign your missile a maximum angle by which the thrust can deviate from the line of motion.

At each guidance iteration you calculate it's velocity perpendicular to the target. Figure out how much it must tip it's engine in order to zero out this component of it's velocity and then clip this to the maximum that it can tip it's engine.

During the first part of it's flight it's going to move somewhat to the right of the straight line in figure #2 but as it flies the engine will zero out this component and it will end up heading straight for the target.

Note that in this scenario there will be only one frame in which the engine has a deflection of anything other than zero or max. If you were tracking a moving target you could get lesser deflections on every cycle as the target moved.

It may not be the elegant solution you are after, but I've found that if I slow the missile, if it's going to miss, as it approaches the target, it effectively tracks and turns quicker and can hit the target. You could increase the turn rate of the missile as it gets closer, rather than reducing the speed, but this might give players a 'wow I'm sure that was going to miss' nasty surprise.

This might not look so great, but it certainly stops the missiles from orbiting, and from the enemy circle-strafing the missile until the fuel runs out.

Here's a demo I've put together of my implementation (the third or forth missile demonstrates this, and again at 1:05) : http://www.youtube.com/watch?v=9uiGMC_nH2w

You can also increase the accuracy of the missile as it approaches the target too (as it has a closer signature to lock to). This is shown in the video too about a minute in. The red circle shows the actual target of the missile. This gives it a chaotic flight path when at a long range, and then straightens out the closer it gets.

Like I say, it may not be the answer you are looking for, but I hope it helps if just a little.

• It is pretty cool. I going for max acceleration, but having the missile slow down is a neat trick (and can be used if you call them "trick missiles"?) – bobobobo Dec 15 '12 at 2:34

# Intuition

Here's one way: Let's rotate your diagram.

Now the rocket is a cannonball!

# Physics

It has a fixed acceleration "downwards" i.e. perpendicular to the vector from its firing location to its target. I drew it above as a dashed green line. Let's call that the reference horizon. (Note that this reference horizon is constant! The rocket was fired from a fixed position with a fixed position as a target.)

We know (from wikipedia) for a cannonball without air resistance, that d = v^2 * sin(2 * theta) / g, where

• d is the horizontal distance travelled (distance between firing location and target)
• v is the speed the projectile was fired at
• theta is the angle as to the horizon the projectile was fired at (angle of fire direction vector from the reference horizon)

Rearranging the equation for g gives g = v^2 * sin(2 * theta) / d.

The constant in the cannonball equation, g, is acceleration due to gravity. We can take it to mean acceleration due to rocket propulsion. That's fine too — it's still a constant acceleration in a constant direction.

# Now what?

Run that equation for g when you fire the rocket. It will tell you how much to accelerate the rocket perpendicularly toward the reference horizon, in order to hit the target. Since the direction of that acceleration is constant, an orbit won't form.

Boom.

• This is a neat approach. I think this is going to cause the rocket to trace a circle, you are supplying the centripetal force required to orbit a circle that happens to impact the target. I believe this may have been the approach used for red shells in Mario Kart, because I always thought they tended to arc circularly – bobobobo Dec 15 '12 at 2:41
• The force applied here is not centripetal. The direction of the force is perpendicular to the reference horizon, which does not change if the target is stationary. This means orbiting behaviour cannot happen. – Anko Dec 15 '12 at 10:15
• I've edited the answer to make that clearer. – Anko Dec 15 '12 at 10:32
• @Anko: I'm not certain your math here works for a moving target, as seems to be the trigger for the OPs case. – Mooing Duck Dec 23 '14 at 17:39
• @Mooing You're right this would only work for moving targets if they're moving predictably and you target the prediction. The question does specifically mention the target is stationary though, in the first sentence. – Anko Dec 24 '14 at 0:32