How to use Cloud Save to create player guilds/clans?

I noticed in the documentation, the newly added features that allow players to add to ‘game data’ saved in Unity cloud can be used to facilitate player guilds, but I didn’t see any examples of this and am struggling to figure out what would be the best practice to make something like this.

I’d imagine it would be something like a Cloud Code script to ‘create a clan’ by writing to the game data value for Clans, and then maybe that value containing a json list of all created clans and their members?

Does anyone know what the best practice would be for having player clans?

Have a list of clans, at the most basic level a List although you‘ll surely want a custom struct to allow for extra data like when the clan was created, which players have admin roles, etc.

Players are assigned a ClanIndex which is an index into this list.

You need to take into account that a player’s clan may have been deleted. And allow clan leaders to add or remove clan members.

It‘s just a starting point but the basics are really just about assigning a clan index to players and managing a clan (team, guild, etc) list of custom data.

2 Likes

Hi Cameron,

We actually have an internal demo for this that we have been planning to turn into an example use case. We have some customers who are already doing this and it was a use case we explicitly had in mind, but we haven’t published an example for it yet.

There are a few of ways to approach it but a creating a Custom Item for each guild is a good starting point, as is using Cloud Code to manage Adding and Removing players.

You can store the ID of the Custom Item for the guild in Player Data, in the Protected Access Class (which players can read, but not modify directly themselves) and have a Cloud Save Index on that field, which you can do in the Dashboard, then you can run a query to get back all members of a guild directly in game.

You might also want to make fields on a guild queryable, to make it easy to find guilds nearby or that speak a certain language or that are public/looking for members.

A variation on this:

If you want to do something simpler, like just have a key like “members” on a Custom Item that is a list of all the members of the guild, that’s not inherently bad either, especially if you have smaller groups.

If you do that way instead you would probably also want to write the ID of the Custom Item representing the guild to Player Data for each player, but you wouldn’t need to add an index if you did it that way because you would just be able to get the Custom Item to get back all the other members.

1 Like

wow, this is very interesting, are there any approximate dates for when the demo project will be ready or where it will be published? Will there be step-by-step instructions for setting up cloud code and database? And most importantly: how many users do you think this approach is designed for? I mean, 100 players can use up the free monthly limit, and if it’s 10 times more, it can be expensive for a lone developer

1 Like