# How to predict future location of a Car in a Navigation Mesh based pathfinding system?

I am developing a car based shooting game in which the Cars have to shoot each other 3/4 times and eliminate it from the game.

I am trying to develop the AI for my cars now. The problem is how can I predict the future location of one of the user cars in a Navigation Mesh based path finding system ? I know its current velocity and direction but since we don't have a grid structure how can I predict its location in the next 2 or 3 seconds ?

One of the solutions I could think of was find the X,Y position of the user's car using his current velocity and direction and then approximate to which node does the point belong. Is there any better system than this which could be employed ?

Any help would be appreciated. Thanks :)

• Personally I think that your solution would probably be the easiest way to do it if you are only looking for a rough estimation of its position. – Elliott Apr 16 '13 at 8:33
• Usually it is a safe assumption to assume the car your AI is targeting will continue in a straight path. While this may not be the case in the event of a turn, in general just guessing the car will move forward at the same speed is fine. You also need to remember not to make the prediction too good otherwise your game will be unplayable as the AI will always be able to hit you. – Benjamin Danger Johnson May 14 '13 at 17:02

I guess you mixed up "path finding" and "object state" (e.g. position, speed, direction, ..). Path finding is used to find a path from position A to position B. As far as I understand, the "Mesh based" algorithm is only used to simplify this "path finding" process, when an actor (e.g. a car) wants to move from position A to position B to reduce the maps complexity for the search algorithm.

All this has nothing to do with the actual position of actors during the game. The actors will (in this case) usually move continuously in one direction until they turn at the next corner. So you can take two observed positions (first / second) of the opponent to calculate the movement vector ( movement = second - first). If you divide it by the time between the observations (duration, in seconds) and multiply it by a time span x (in seconds), you get the relative position of the opponent, if it continues to move that way for x seconds. The estimation is calculated by: estimated = second + (second - first) * ( x / duration), where first, second, estimated are vectors and x, duration are scalars (time spans in seconds). The time spans don't need to be seconds but need to have the same unit (e.g. frames, time steps, ...).

Regards Stefan