Making a league

Hello
Currently, I am creating a racing game. Right now, I am trying to make a league so that if you come first 1st in a race for example, you get 8 points, the next person gets 7, then 6, etc. etc.
However because Ive never done anything like this Im a bit unsure of what method I should use to create the league.
It isn’t multiplayer, but should I have it so that you have to get a certain amount of points within a certain amount of matches to win (like Fifa Ultimate Team Seasons) or should I have a full-blown league, but make up who comes where in the race except for your player or should I try to somehow track the AI’s finishes in the race (even though they’re just instantiated prefabs.
Any advice would be welcome as Im really stuck here

Thanks

Dok

Create a leaderboard class. It contains an array of PlayerRank. PlayerRank is a class containing the info you need for the leaderboard, name, points, car brand or others.

The array of your leaderboard is reordered at the end of a race. So when you finish, you grab the leaderboard and for each runner, you update the PlayerRank values. Then at the end, you reorder your array. The array is kept in PlayerPrefs so you can call it back next time you play. You would convert your PlayerRank to string, most likely overriding the ToString method and concatenate into a large string that you store with PlayerPrefs.SetString. When you run the game next game, you fetch that string and turn it back into PlayerRank values that you keep in RAM for the time of the game.

EDIT: I came up with a fully explained solution :

You can try declaring an empty “place” variable in each car, then fill that variable with a number for each place (first place is car 1, 2nd car 2…) then create a for loop or a really long if else script that assigns however many points to each car. (Idk how to code exactly but I understand concepts)

If player car place= 1st place
{
Then player car points = 8
}

I don’t know exactly how to code it because I don’t know all that much, nor do I know what your game objects are called, but I hope this helps.

I for one, would suggest having a trigger at the end of the race, with a script, that would assign 8 points to the first car that collides with it, then 7, and so on. If it’s a circuit race, the same trigger can be used, but its behavior controlled by a variable that counts how many times a car has passed through and then assigns points.

You should create a script, let’s call it CarDetails, that should contain a getter and setter for a _points variable, attach it to each car prefab, and in the trigger’s OnTriggerEnter() or OnTriggerEnter2D(), depending on what you’re using, call the collider’s setter.

Your CarDetails script can also contain other things like names, car types, colors, whatever.

Afterwards, you can do whatever you want with the values, like storing them in your game manager singleton object, or in player prefs.

Look up triggers: Unity - Scripting API: Collider.OnTriggerEnter(Collider)
and singletons:

http://unitypatterns.com/singletons/

EDIT: I think fafase’s answer also works well.

Did you pass Algebra in school? Then make some functions!