Sign In Register

How can we help you today?

Start a new topic

Conditional leaderboard update

I've followed the guide on setting up Leaderboards in Unity and have it working now with updating a 'score' attribute. However, for our game we also want to store information about what level the user was at, at the time of setting the high score. I thought I could do that with making a 'level' attribute in my Post Score event and setting its Default Calc to 'Last'. This does work as long as the user set a new high score, but the 'level' attribute (a long with everything else) is being updated every time I call the event, which means that if users level up, their leaderboard entry will be updated with their new level next time they set a score, even if this score was not higher than the one already in the leaderbord. Is there some way of setting up a condition that makes leaderboard data only update if a given attribute fulfils a given criteria. All I want is to be able to check if the new 'score' would result in a high score and if it does, then I want to set all the other data. If not, nothing should happen.


Hi Heino,


Sounds like Partitioned Leaderboards might be the solution you're looking for.
Have a look at that tutorial and let us know if you need any help.

Thanks,


Oisin

Sorry Heino, actually it sounds like you are looking for a new leaderboard attribute type.


We're planning this in an upcoming release.
I can update you when this feature is ready if you like?

Thanks,

Oisin. 

It'd be nice to be updated about it when it gets implemented, yes. However, we're on a pretty tight schedule at the moment, so we can't wait too long.

However, the partitioned leaderboard approach might work for us, with a few work-arounds. We know there is a limited amount of levels that the players can be in, so it's possible to use the partitioned leaderboard for keeping track of the scores on different levels. It would be nice to be able to also get one combined leaderboard for all levels. I could do that through Unity by simply doing a LeaderboardDataRequest for each partition of the leaderboard and then combine them, but I think it'd be nicer to do it through Cloud Code. I'm not really sure how to do that though. Could you help me out on that? I'm imagining sending a JSON attribute from Unity called 'levels' that'd be formatted like:

"levels": {
"0": 1,
"1": 1,
"2": 0,
"3": 1
}

 

The first number would be the level and the second number would be whether to get that partition or not (1 meaning yes, 0 meaning no). I'm just not very skilled with Cloud Code yet, so I don't know how to query the JSON request through Cloud Code and then get the Leaderboard data for the given levels. Is this even possible?

Login to post a comment