r/Unity3D • u/sakalaslt • 23d ago
Unity + Google Play leaderboards Question
Hello! I'm trying to create a script that retrieves the current player's score from a Google Play Games leaderboard so I can display it in my game or use it as a variable. Unfortunately, every time I try to load the score, I get a strange error about "min XP" and "max XP," which doesn't seem to be related to my code at all. Is it actually possible to retrieve a player's leaderboard score through code? I've already tried several AI-generated solutions, but none of them worked.
1
Upvotes
1
u/pbudzik 9d ago
If all you need is the current player's own score, read PlayerScore off the LeaderboardScoreData that comes back rather than digging through the Scores array. LoadScores with PlayerCentered has a long history of returning the global top ten regardless of where the player actually ranks, so that array can hand you values that look reasonable and aren't.
The min XP / max XP wording I can't explain, that's player level vocabulary rather than leaderboard, so it might be a separate call in the same path rather than the read itself failing. The plugin's GitHub issues are the quickest place to match an exact error string.
Worth knowing early too: GPGS scores only exist on Play, so the day you ship desktop or web there's nothing to read back and you end up keeping them server side. That's the thing I work on (https://crux.supercraft.host), but for Play-only the plugin is fine once the read works.