Game Development Community

Position in racing game

by Taras (TSK) Anatsko · in Torque Game Engine Advanced · 07/06/2007 (2:06 pm) · 5 replies

Hi, can someone help me with how to calculate position of the player in the race not only on the finish. Like most Racing Games have... When you overtake the other players.

#1
07/06/2007 (3:00 pm)
The farthest I ever got in response:

www.garagegames.com/mg/forums/result.thread.php?qt=46253

It'd be great if someone posted up what they actually use. :D
#2
07/07/2007 (5:56 am)
.
#3
07/09/2007 (10:31 am)
You need to have a path along the track centerline to do this correctly. Usually you have some structure like this for AI drivers to be able to run the race. You then find the closest point on the track centerline to each vehicle and store it as a 0 to 1 value... 0 being the starting line and 1 being the finish line. Then its a simple sort for position.
#4
07/09/2007 (10:50 am)
Tom is correct, most racing games have a preferred line for the AI to drive and would calculate position based on this. These would be waypoints/markers that the player doesn't see but are there in the mission. You would most likely need them about every 5-10 meters for it to be precise. Sounds tedious but this is the way to do it and the way most racing games do it.
#5
07/09/2007 (1:41 pm)
In the last road racing game i worked on we had a more complex system.

We would use a list of quads to define all the road surfaces. This way we could calculate the centerline and also know how wide the road was at any point. This information was used for the AI to know when and to pass other players and the basic layout of the road.

Still a centerline isn't really where you want to drive anyway, so on top of this we had a "driving line" which was the optimal driving path and included the maximum speed you should be going at any point for a perfect run. The AI would then use this to decide when to accelerate or brake for a perfect lap.