Feature Request (Get My Rank)

28 views
Skip to first unread message

vgmi...@gmail.com

unread,
Jul 11, 2019, 5:29:37 AM7/11/19
to firebase-unity-solutions
Hi,

I went through the Fire base Leader-board api and it was useful. But i ended up in an issue where, when my player is not in the top 10 scores, how do determine his ranking using the GetUserScore() method. 

Regards,
Kumar KS.

Dane Liergaard

unread,
Jul 11, 2019, 2:17:10 PM7/11/19
to vgmi...@gmail.com, firebase-unity-solutions
Hi Kumar,

This is a tricky problem because, the way Realtime Database is set up, it's made so you don't have to iterate over all the scores to find an entry. 

If you want to get a person's rank in real time, it means counting the # of scores that are better than theirs, which could mean a lot of iterations, and it gets worse the more popular a game is!

Another potential solution, if the ranking doesn't have to be in real time, is to have a periodic Cloud Function that sorts all the current scores and ranks them by adding a "rank" field to each one. Then you could use that data in your display. The obvious downside is that you don't get the rank of a score as it's posted.

However, for the first method, I haven't tried making a RTDB query that sorts by the score, starts at the user's score, pulls all the better scores with no limit and just calls "ChildrenCount" on the result. It's possible this would be cost effective at various score counts, and might be worth trying.

Best,
DZ

--
You received this message because you are subscribed to the Google Groups "firebase-unity-solutions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-unity-sol...@googlegroups.com.
To post to this group, send email to firebase-uni...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-unity-solutions/cf56257e-c3c3-4bf3-8076-84191a7bb6be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Dane Zeke Liergaard
Cloud DevRel, Gaming
Seattle
Reply all
Reply to author
Forward
0 new messages