Search Unity

Question Any way to just set score instead of add?

Discussion in 'Leaderboards' started by jawnwee, Mar 29, 2023.

  1. jawnwee

    jawnwee

    Joined:
    Nov 4, 2019
    Posts:
    33
    Hi,

    Our primary method of authentication is through Firebase (doesn't seem like there is a way to link that + Unity Auth yet). So a couple things on top of my mind are the following:

    1. Does sign-in anonymously persist over app deletion / install (on same device) with the same id?
    2. We want to do as few writes as possible (while the service is free for now, it seems as though this is something we don't want to overlook down the road -- pricing states "We ask you on average to restrict usage to: 500 Calls per MAU"
    - instead of doing a write every time a players score is increased, we would maybe store this value and actually do the write on their next session, but locally move their ranking around, etc.
    - how restrictive is the number of calls per MAU here? is this including both reads and writes in the long run?
    3. To my main question, is there a way we can just set the score instead of an add? This way, we can just store what a running sum of the score is (on our db) and update this number whenever we choose.

    Thanks!
     
  2. StevenStip-Unity

    StevenStip-Unity

    Unity Technologies

    Joined:
    Apr 7, 2021
    Posts:
    22
    Hi, thank you for your questions I'll try to answer them in line:
    1. Does sign-in anonymously persist over app deletion / install (on same device) with the same id?
    Leaderboards, like many other UGS products uses the Authentication package for the player ID's. The anonymous login option stores the player identifier on the device, this means that if you wipe the data for the game then the ID will be reset as well so deletion of the app on the same device can reset the data for the player.

    2. We want to do as few writes as possible (while the service is free for now, it seems as though this is something we don't want to overlook down the road -- pricing states "We ask you on average to restrict usage to: 500 Calls per MAU"
    We aimed for the Fair Use limits to be something that doesn't get in the way of developing a great game but instead promotes the use of best practices.

    The number is an average over all players and please don't worry about the average at a small number of players we know that generally is just QA or development happening.

    - instead of doing a write every time a players score is increased, we would maybe store this value and actually do the write on their next session, but locally move their ranking around, etc.
    This is a good practice, writing at the end of a round of the core loop of the game is generally what we would expect developers to do.

    - how restrictive is the number of calls per MAU here? is this including both reads and writes in the long run?
    This is including both reads and writes.

    3. To my main question, is there a way we can just set the score instead of an add? This way, we can just store what a running sum of the score is (on our db) and update this number whenever we choose.
    Yes, this depends on how you store your scores. If you want to do it this way you can report the aggregate and just use the latest score for the player.
    upload_2023-3-30_10-58-49.png
     
  3. EmilF_Unity

    EmilF_Unity

    Unity Technologies

    Joined:
    Jun 10, 2022
    Posts:
    18
    Hi jawnwee,

    regarding your comment around linking Firebase auth with Unity Authentication, you can use our OpenID Connect providers to set that up. You can find more information on setting up a custom provider here and details on how to integrate with the Unity Authentication SDK here. Hope that helps!
     
    SebT_Unity likes this.
  4. jawnwee

    jawnwee

    Joined:
    Nov 4, 2019
    Posts:
    33
    Thanks all for the detailed ideas and approaches!

    So far everything is really easy to use and has just enough capabilities for the use cases I'm looking for!