• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] IDEA: How to make position in race function?

Status
Not open for further replies.
The idea is to put in a racing game a function that checks what is the postion every racer unit amongst his opponents on the racing terrain. Is he 1st,2nd,3rd..? And display a message what is the postion of your racer every time he gets outdistanced or outdistance another racer. Any idea how this will happen?
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
The easiest way would be to define a path that your racing track follows.
Then loop through all racers and find the closest point on the path for each racer.
For any given point on the path, you can get the total length until the start/finish line.

Then you have a value that you can use to sort the racers.
Then you just have to apply some sorting algorithm to get the racers' positions in the race.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
If you take a look at Forza, Need 4 Speed, etc, you will see that it is also not perfect in every situation.
But if you have a 95+% accuracy on it, its good enough. (Apart from 100% accuracy on who passed the finish line first.)
 
Status
Not open for further replies.
Top