Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question How to reset all Cloud Save values of registered users using the Leaderboard Reset event?

Discussion in 'Cloud Code' started by Rob_Elias, Apr 29, 2024.

  1. Rob_Elias

    Rob_Elias

    Joined:
    Mar 21, 2014
    Posts:
    18
    Hello! I want to reset the values saved by the players in Cloud Save every time the Leaderboard is restarted. So far I know that when the leaderboard is reset, a 'reset' event is emitted that can be captured by the Cloud Code Triggers.
    Can you suggest a way to reset all user values using this event? (It cannot be through the user ID in the leaderboard since the maximum is 1000)
     
  2. samg-unity

    samg-unity

    Unity Technologies

    Joined:
    Mar 23, 2021
    Posts:
    45
    Hi @Rob_Elias

    Depending on how many user values you may need to update, you may run into some current limitations with Cloud Code in terms of execution time (max 15 seconds) and this could be fairly costly? Soo I'd first consider whether you have to reset all users data or could you compare a field in the user data with a global value (e.g. a timestamp or a counter value in a Cloud Save custom data field or possibly remote config) - if the two don't match, then the game client/ Cloud Code operation could consider the user data "reset".

    Otherwise have a look at this sample that rewards the top 5 users https://docs.unity.com/ugs/en-us/ma...ata#Update_top_5_player_data_using_Cloud_Save as I think that could be modified to handle your use case.
     
    Rob_Elias and GabKBelmonte like this.
  3. Rob_Elias

    Rob_Elias

    Joined:
    Mar 21, 2014
    Posts:
    18
    Thank you very much for the help.
    Thinking a little more about this, I came to the conclusion that the Leaderboard reset all the values, so when I start the game I can ask if there is a record in the leaderboard used and if there is not, send a script to be executed to reset the default values from the user to start the new season. :)