Positions of players in a car race?

Hi all
I want to know what is the algorithm to calculate the positions of players in a car race.
Also, how to know when a car is going in the wrong direction?
Thanks.

It’s quite complex question, imho. In short, I used waypoints setted up along the track. If movement vector is directed from lower to higer waypoint - we drive right . Here my old experiments (ODE + AI, based on waypoints): panda3d.org.ru/files/reroll.zip

OK thanks!
had also thought of this before, it seems very well.
I guess this also can be used to find the positions of the players (1st, 2 …). If Player 1 passes through a higher waypoint, the player 1 is first in this instant…

Yes, In my example I also find player positions by similar way (see left top corner). Small white box shows the next waypoint

:smiley: ok excuse me, only had executed the script editor.py and not main.py
Thanks!!

If your waypoints are fairly sparse, I imagine that you can refine the above suggestion for finding the position of a car as follows:

  • Consider each neighbouring pair of waypoints to define a line segment, defined as wayPoint + k*nextWayPoint, where “k” is some value that we will be attempting to find.
  • First, define the car’s position as shown above, by essentially finding which segment the car is currently in.
  • Now find the point on the segment that is closest to the car’s location; specifically, find the value “k” in the equation above that defines that point.
  • Cars are then ranked first by which segment they are in, then by their “k” within that segment.

With a little more work you could even use this to calculate roughly what percentage of the track the car has run in a given lap, I believe.