Connect players

Try profiles, rankings, friends, and guilds with two accounts.

Call your existing player A and create a second player, B. Display their names, compare scores, and connect them through friends and guilds.

1. Add profile, ranking, and guild settings

From Add features, add Friends & Profile, Rankings, and Guilds. Profiles and friends require no table entries.

Add a row under Tables → Rankings → Ranking and enter the following values.

FieldValue
IDadventure
Sort directiondesc (highest score first)
Sum scoresOff
Minimum score0
Maximum score1000000
ScheduleLeave empty

Do not add ranking reward rows. This ranking uses each player’s most recently submitted score.

Under Tables → Guilds → GuildRole, add the following two rows. Paste the entire linked JSON into each Permission policy cell.

IDPermission policy
masterMaster policy. Allows changing guild settings and approving requests
memberMember policy. Does not grant guild administration permissions

Add a row to Guild and enter the following values.

FieldValue
IDadventure
Initial / maximum capacityBoth 10
Rejoin cooldown0
Maximum memberships / master rolesBoth 1
Master rolemaster
Member rolemember
Master inactivity periodLeave empty

Deploy from Publish → Calculate server differences, then click Update the Unity project.

Download the social features template. In the management console’s Tokyo region, open Deploy → Stack list → Create stack. Name it adventure-social, select the file under Template data, and create it.

FeatureService / namespaceSettings
Profiles and friendsFriend / adventure-friendStores each player’s name and friends
RankingRanking2 / adventure-rankingadventure; highest score first, uses the latest value without summing
GuildsGuild / adventure-guildType adventure; 10 members, one guild per player, no rejoin cooldown

Your existing adventure and character settings remain available after adding this stack.

Add the social panel in Unity

Stop Play Mode and uncheck Adventure Characters on Extensions. Keep the adventure panel on the left.

Place AdventureSocial.cs in Assets/AdventureExtensions, then add Adventure Social to Extensions. It uses the signed-in Gs2ClientHolder and Gs2GameSessionHolder.

Place AdventureSocial.cs in Assets/AdventureExtensions, then add Adventure Social to Extensions. Assign the scene’s AdventureLogin to Login.

Enter Play Mode to see the social panel on the right. Scroll within it to reach the lower buttons.

Switch between A and B

Click Copy my ID on the right and save it in a text editor as player A’s ID. Set Display name to Adventurer A and click Save my name.

Stop Play Mode. On the login object, change PlayerPrefs Account Store → Key Prefix from adventure.main to adventure.social-b, then enter Play Mode. The first time, account B is created.

To switch accounts, stop Play Mode, set Key Prefix to adventure.main for A or adventure.social-b for B, and restart. Logging in with the saved account restores the same player ID.

Stop Play Mode, change Account Slot on AdventureLogin from main to social-b, then restart and log in. The first time, account B is created.

To switch accounts, stop Play Mode, set Account Slot to main for A or social-b for B, then restart and log in. The saved account restores the same player ID.

For B, click Copy my ID and save the ID. Set the display name to Adventurer B and save it. Enter A’s ID in Other player’s ID and click Read their name. Adventurer A appears.

Switch to A, enter B’s ID, and read their name. Seeing B’s name confirms that you can look up another player by ID.

Names are stored in Friend’s public profile.

await Client.Friend.Namespace(FriendNamespace).Me(Session).Profile()
    .UpdateProfileAsync(publicProfile: displayName);

await Client.Friend.Namespace(FriendNamespace).User(targetUserId)
    .PublicProfile().ModelAsync();

2. Submit scores and compare rankings

This ranking uses the most recently submitted score, rather than keeping each player’s personal best.

The list shows rank, display name at submission, score, and player ID. Updates can take up to five minutes to appear. If your score is not visible yet, wait a little and click Read rankings. Check each result before moving to the next row below.

ActionResult after reading rankings
As A, enter Adventurer A and score 100, then click Submit scoreA has 100 points
Switch to B, enter Adventurer B and score 200, then submitB has 200 points and ranks above A
Switch to A, enter Adventurer A and score 300, then submitA has 300 points and ranks above B
Submit 50 as AA’s score becomes 50 and ranks below B
var ranking = Client.Ranking2.Namespace(RankingNamespace)
    .GlobalRankingModel("adventure").GlobalRankingSeason(Session);
await ranking.PutGlobalRankingAsync(value, displayName);
await foreach (var item in ranking.GlobalRankingsAsync())
{
    if (item != null) message += item.Rank + ": " + item.Metadata + " / " + item.Score + "\n";
}

The display name is submitted with the score. Changing only the profile name does not change the ranking name. Submit another score with the new display name to update it.

3. Send and accept a friend request

  1. As A, enter B’s ID in the other player field and click Send friend request.
  2. Click Read friends. B is not listed yet because the request has not been accepted.
  3. Switch to B, enter A’s ID, and click Accept their request. A appears in the friend list.
  4. Switch to A and read the list. B appears.
  5. As A, enter B’s ID and click Remove friend. B disappears from A’s list. Switch to B and read the list again; A has disappeared there too.

Use player IDs to specify both the request recipient and the sender whose request you want to accept.

var me = Client.Friend.Namespace(FriendNamespace).Me(Session);
await me.SendRequestAsync(targetUserId);
await me.ReceiveFriendRequest(targetUserId).AcceptAsync();
await foreach (var item in me.FriendsAsync(withProfile: true))
{
    if (item != null) message += item.UserId + " / " + item.PublicProfile + "\n";
}

4. Join a guild

Switch to A and click Create an adventurers’ guild. The new guild ID appears in the input field; save it. The member list shows A with the master role.

  1. Switch to B and enter the saved ID in Guild ID.
  2. Click Join or apply to this guild. Initially the guild allows anyone (anybody), so B joins immediately.
  3. Click Read members to see A and B. B has the member role.
  4. As B, click Leave this guild.
  5. Switch to A, enter the same guild ID, and click Master: Require approval. The join policy becomes approval.
  6. Switch to B and click Join or apply to this guild again. This time only a request is sent; B is not yet in the member list.
  7. Switch to A, enter the guild ID and B’s player ID, and click Master: Approve their request. B is added to the member list.

Creating and joining guilds uses the signed-in player’s session.

var me = Client.Guild.Namespace(GuildNamespace).Me(Session);
await me.CreateGuildAsync("adventure", "Adventurers' guild", "anybody");
await me.SendRequestAsync("adventure", guildName);

To approve requests or change the join policy, obtain a guild session using A’s permissions first. This is implemented in ManageGuild() in AdventureSocial.cs.

Finish with A selected. In the next chapter, you will send event rewards to this player.

Next: Run an event