- Home /
How to create a ranking system for a racing game.
I'm making a racing game and I've got all other aspects of the race logic working except for the ranking. I'm trying to get player's the position (1st, 2nd, 3rd etc).
My current approach is :
Place multiple checkpoints on the race track.
Check whose ahead by using Vector3.Distance
So far this approach works pretty well but the thing is, I can't seem to get it to decrease my rank by 1 when I pass a car and vice versa.
For Example, When I pass a car, I become 1st and when a car passes me I become last. Does anyone know how I can get the ranking system to work flawlessly?
Here's part of the code I'm using to check whose ahead, it's attached to every car :
for(var i : int = 0; i < cars.Length; i++){
if(isPlayer){
//If we are a checkpoint ahead, then we become first
if(checkPoint > cars[i].GetComponent(CarRank).checkPoint){
rank --;
}
//If we are on the same checkpoint. Compare our distances and change ranks accordingly
if(checkPoint == cars[i].GetComponent(CarRank).checkPoint && distanceFromCheckpoint < cars[i].GetComponent(CarRank).distanceFromCheckpoint){
rank--;
}
else{
rank ++;
}
//If we are a checkpoint behind, then we become last
if(checkPoint < cars[i].GetComponent(CarRank).checkPoint){
rank ++;
}
}
}
Your answer
Follow this Question
Related Questions
Ranking System in Racing Game 1 Answer
ranking in race Game 2 Answers
How can I make a "Fastest Lap" scoring system for a racing game? 2 Answers
Rotation of an object on button down. 1 Answer
Car AI help 0 Answers