9
\$\begingroup\$

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.

enter image description here

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

enter image description here

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.

\$\endgroup\$
3
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Dec 17, 2012 at 12:45
  • 1
    \$\begingroup\$ Actually, this was the answer I used \$\endgroup\$
    – bobobobo
    Commented Dec 17, 2012 at 17:00
  • \$\begingroup\$ possible duplicate of How to prevent homing entities from orbiting their targets \$\endgroup\$ Commented Jan 14, 2013 at 5:46

3 Answers 3

5
\$\begingroup\$

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.

\$\endgroup\$
4
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ 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"?) \$\endgroup\$
    – bobobobo
    Commented Dec 15, 2012 at 2:34
4
\$\begingroup\$

Intuition

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

a rotation of the original problem illustration

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.

\$\endgroup\$
7
  • \$\begingroup\$ 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 \$\endgroup\$
    – bobobobo
    Commented Dec 15, 2012 at 2:41
  • \$\begingroup\$ 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. \$\endgroup\$
    – Anko
    Commented Dec 15, 2012 at 10:15
  • \$\begingroup\$ I've edited the answer to make that clearer. \$\endgroup\$
    – Anko
    Commented Dec 15, 2012 at 10:32
  • \$\begingroup\$ @Anko: I'm not certain your math here works for a moving target, as seems to be the trigger for the OPs case. \$\endgroup\$ Commented Dec 23, 2014 at 17:39
  • \$\begingroup\$ @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. \$\endgroup\$
    – Anko
    Commented Dec 24, 2014 at 0:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .