Targeting a vehicle with known constant velocity is simple, and collision is guaranteed (see Predicting enemy position in order to have an object lead its target, Find meeting point of 2 objects in 2D, knowing (constant) speed and slope). Imprecise AI can be modeled by adding a small error factor.

But how would one go about targeting a vehicle whose movements are more complex? Perhaps it's evading the AI or another game object.

I've been thinking about how I'd do it myself in a FPS (in which bullets have finite speed) and think there might need to be at least couple of targeting modes based on the target's movement in the previous second or so:

  • If it's near linear (peak acceleration in a certain range) target with the linear model
  • If it's highly irregular (perhaps size of bounding box of recent positions could be used?) , target at an average

For now I can assume 2d space, AI is stationary and projectile is unguided and moves linearly.

  • 1
    \$\begingroup\$ If you have time to collect data about the irregular moving object, then you may interpolate its most likely next move and shoot there. The more data you have, the more precise this will be. \$\endgroup\$
    – Michael K
    Mar 22, 2012 at 16:43
  • \$\begingroup\$ Don't know if your just talking bullets or not. But there is also smart ordinance. A stinger launched from an RPG can track the heat of an aircraft for instance. \$\endgroup\$
    – Steve H
    Mar 22, 2012 at 19:28
  • \$\begingroup\$ @SteveH - just unguided "bullets". Have clarified in question. \$\endgroup\$
    – e100
    Mar 23, 2012 at 12:02

1 Answer 1


Random thoughts (no code)...

In real life, one targets a vehicle with complex movement by trying to figure out what that movement is so as to anticipate it. If you are writing code for AI to target AI, then you should create a targeting AI that is derived from the target AI. For example, if your target will run for cover if near by, the targeting AI should be able to anticipate this movement.

On the other hand if you are trying to target humans with AI, it's going to be a lot more difficult. Random targeting could work, but may look just "random", which may or may not be an issue for your game.

To come up with a solution, one thing you can do is mentally separate out the problem into the different pieces of trying to shoot something...

Tracking Ability

In order to hit a target with an aimed device that can move, one must be able to track and move the device to follow the target. The targeter observes the target moving, and moves their aim to follow. If a tracker has a limited amount of movement, then its tracking ability will be hampered and it may have a hard time tracking some things. but if the tracker has a large amount of tracking freedom, it can potentially track many things. Think about the difference between a tank turret and you pointing at something with your finger.

Tracking Speed

Another factor is how fast the tracker can track. If it is very slow (think "tank turret"), then it can't track a target that moves fast. Instead it has to rely on anticipation of the target's path. On the other hand a tracker with "fast" speed can quickly move to a target's new location.

Tracking Reaction Time

A third factor in tracking is the reaction time of the tracking. That is, when the target changes direction, how fast can the tracker react? The ultimate tracker is one with fast tracking speed and instant reaction time - it can track any change.

Target Recognition

How well can the targeter recognize a target? If one is tracking a target in a complex environment, there may be times when the targeter fails to recognize or "loses" the target. The faster the targeter can recognize a target, the better it will do. The less likely it is to lose a target, the better it will do.

Shooting Reaction Time

Just because the target shows up in the crosshair for a brief moment of time doesn't mean that a shot will happen. Can the tracker react fast enough to pull the trigger? Really bad trackers with really bad reaction time won't hit anything. Really good trackers with really good reaction time will hit anything, because they only need the slightest bit of time on target.

Anticipating Movement

Anticipation of movement is another factor. This is the difference between just trying to track to where the target is now, versus tracking to where you think the target will be. If a tracker can anticipate, they can track the target better, and get more chances to have the target in the crosshairs, and thus improve their ability to get a shot off based on their reaction time. Zero anticipation trackers would just automatically move the aim towards the target, irrespective of the target's actions. The worst case is a tracker who's speed is slow with no anticipation trying to track a simple moving target. Imagine a target that just steps to the left and then to the right every few seconds. A slow tracker would just keep bouncing the aim back and forth, never fast enough to get the target. Only if the target stopped moving could the tracker hit it, and only then if the stop was long enough for the reaction time.

Modelling Target Movement

As mentioned up top, the tracker can anticipate the target by modelling its movement, which is not necessarily that hard to do. If a vehicle is driving at some speed, there are a finite number of places that vehicle can be in the next second, and they are laid out essentially like a triangle in front of their movement. The faster they are going, the tighter the triangle is. The faster they can turn, the wider it is. A really fast vehicle that can hardly turn (like a rocket) has a very small narrow potential path. A slow one that can turn very well has a much wider potential path. It's like those backup cameras on some cars that overlay lines showing you where your car will go if you keep driving as it is now, plus where you potentially could go if you were to turn the wheel more.

So with that in mind, you should put your "potential target space" box in that potential path space. If you know your target has a tendency to veer from side to side, your target box needs to be wide enough to encompass all possible movements. If your target is pretty linear in their movement, you can make your target box much smaller and centered on the anticipated location of movement. I think this kind of thinking will help you make a single solution to tracking that doesn't really differentiate between linear and non linear anticipation. Linear tracking is simply anticipation with a higher level of confidence (smaller targeting box), while random tracking is low level confidence tracking (larger tracking box).

Of course this gets challenging if the target is standing still, because it has the potential to move in any direction. But of course if it sits still too long, it's an easy target even for the slowest tracker.

Target Psychology

Consider what you would do if you suddenly had shots landing to your left. Would you run at them? NO! You'd run to the right. Or maybe you'd run for cover. But then maybe the targeter specifically shoots at the cover location so then you don't run for it.

Capacity to Learn

Potentially your targeter can learn from experience. Suppose at first they have no idea of the vehicle's potential movement. They don't know how fast it can go, or how fast it can turn. Observing it in action though will teach them what this is. Meaning that the first time they try and track one, they may not do very well. But they learn the movement behavior, and do better on subsequent tries.

Further Reading

A bit of googling after writing this led met to this manual for rifle marksmanship...


Might be some ideas in there about how a real person would/should/could aim and track.

  • \$\begingroup\$ Wow - that's given me a lot of food for thought - thanks! \$\endgroup\$
    – e100
    Mar 22, 2012 at 16:48
  • \$\begingroup\$ Yea I dunno if I have an exact answer for you really, just some things to think about. As much as there is math in tracking, I think there's also psychology too. \$\endgroup\$
    – Tim Holt
    Mar 23, 2012 at 1:24
  • \$\begingroup\$ Indeed - the notion of identifying what kind of target it is and therefore its likely pattern of behaviour is an obvious one in retrospect. Could be extended to understand what its mode/state is as well (e.g. static/unaware/in combat/evading etc) \$\endgroup\$
    – e100
    Mar 23, 2012 at 10:15

You must log in to answer this question.

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