View Single Post
Old 02-25-2008, 04:36 AM   #2
David Sattar
Junior Member

Activity Longevity
0/20 18/20
Today Posts
0/11 ssssssss3
Default Lead Pursuit

How about looking into the question of smarter NPC pursuit, pulling lead on a fleeing player to cut across the corner to catch them up ?

Consider the basic situation of an NPC / monster chasing a character who's running across their path. Say you the player are running West to East, and the NPC is running South to North. At time (1) you are directly north of the NPC.

(1)----------(2)--> Your path

NPC chasing you.

You both start running at time (1). If the only check the NPC makes on your position is when it started chasing you, then at time (2) you will have safely escaped to the East.

But of course, the NPC makes a series of position checks, maybe as often as every frame, certainly at least every few frames or every second, which results in the NPC's path curving to the east as it chases you. This is 'pure pursuit' with the attacker always aiming directly at the defender. Now here's the thing... Assuming that you and the NPC are running at the same speed the NPC can never catch you. Which may be good for the game play, but pity the poor monster, fated never to catch a tasty player... So a smarter NPC ought to 'pull lead' on the player being chased, aiming a little in front of the player to 'cut across the corner' and thus catch up to the player.

In aircraft combat this is known as 'Lead Pursuit', and it may be a solved problem - you'd have to check into flight simulator coding to find out. In fighter combat the opposite technique 'Lag Pursuit' where the attacker aims *behind* the defender is also very useful where the attacker is faster than the defender, when guns, unguided rockets and rear-quarter-only missiles are being used. For monsters armed with teeth & claws, chasing players using lag pursuit probably has no use though.

In any case, the NPC needs to decide how much lead to pull in order to catch up to a fleeing player. Decision factors are going to be the angle of their paths and the difference between their speeds. If you want to get really fancy, then considering the terrain becomes a factor. It may be worth giving up the shortest path lead pursuit in order to take a longer path that allows the NPC to cross a marsh using a bridge, rather than slogging slowly through the marsh in a lead pursuit of the player.

I'm just a game player, not a designer or programmer, so apologies if this whole topic is already considered 'solved' by the community :-)

>> Dave Sattar <<
David Sattar is offline   Reply With Quote