question

Kornel Lajos Varga avatar image
Kornel Lajos Varga asked

Globally incrementable variable,How to use Global Variables in PlayFab

hi I am using Unity with the playfab SDK and I would like to create a game where multiple users can contribute to one progress at the same time.

For example lets say that it is an idle/tap construction game where multiple buildings are being constructed by tapping them, the user should be able to increment the construction progress while other players do the same to the same building. So these buildings are not relative to a local progress but a contribution based one between multiple players.

To avoid clash I was thinking to use player specific data like "building 1" "contribution 1000" then the client could request from the server the overall progress of the "building 1", however I am really lost in how to do it with Playfab.

,

I would like to use Playfab in Unity to do the following:

Multiple game type categories which should be linked with some data.

Each player can contribute to each category "score" and should be able to see the progress.

For example the game could be "construction of buildings". Lets say there are 5 buildings the players can contribute to. Tapping one building contributes to one value while tapping another would contribute to another.

I was thinking to use player data to store something like title - "burger house building", value (contribution) - "102340"

However, this would mean that the server would have to gather the data from all the players when i'm requesting the overall per building progress, or is there a way to store some kind of global variable where multiple users can increment the value at the same time without clash?

Title Data
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

If the max number of users in the set contributing to the data isn't large - say, less than 1,000 - a Group Entity might work, though you'll need to make sure to have retry logic with an exponential backoff for cases where simultaneous write attempts occur. If you want to try to aggregate data across large numbers of players, you'd need to use an in-data memory store, like Redis.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Kornel Lajos Varga avatar image
Kornel Lajos Varga answered

@Brendan Thank you for the feedback, I will look into the group entity, however I hope to have more than 1000 users later on. This is why I was thinking to store the contribution per user so there is no conflict ever. However in that case a request handling has to be implemented on the server which gathers the data from all users. Is that not a plausible way?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.