Unity makes leaderboards so easy


Unity keeps amazing me.

Adding authentication & a leaderboard to Panda & Crow: 7 Days Europe?! took no time.

First. make sure the player is authenticated:

await UnityServices.InitializeAsync();
await AuthenticationService.Instance.SignInAnonymouslyAsync()

Then access the leaderboard service:

await LeaderboardsService.Instance.AddPlayerScoreAsync(leaderboardId, levelDuration);
LeaderboardScores scores = await LeaderboardsService.Instance.GetPlayerRangeAsync(leaderboardId, new GetPlayerRangeOptions { RangeLimit = 4 });

Now, when a player succeeds in a level, I'm sending the time it took them (as double) to the map's leaderboard and then get the +/- 5 leaderboard entries around  the player's score for some friendly competition.

All in just a few line of code.

Scores are stored on Unity servers, free for the first 50k MAU. Brilliant move, Unity.

Next I'll store level progress. Also a Unity service.

Files

Glide Arcade 2023-09-02 WebGL.zip Play in browser
Sep 02, 2023

Leave a comment

Log in with itch.io to leave a comment.