Search Unity

Third Party Connect Photon with Google Play Games user profile.

Discussion in 'Multiplayer' started by MaciejKusztal, Mar 6, 2021.

?

How to connect Photon and Google Play Games?

  1. Implement and add the user's nickname and avatar after joining to Photon room from Google play games

    0 vote(s)
    0.0%
  2. Implement and add the user's nickname and avatar after joining to Photon room from Google play games

    1 vote(s)
    100.0%
Multiple votes are allowed.
  1. MaciejKusztal

    MaciejKusztal

    Joined:
    Feb 4, 2020
    Posts:
    87
    Hello, I use Photon in my multiplayer game. Lately, I added google play games auth. I would like to show the user's nickname after joined to the room from Google Play Games and also the user's avatar. How Can I do it?
    Code (CSharp):
    1.  
    2. public override void OnJoinedRoom()
    3.     {
    4.         Debug.Log("Client successfully joined a room");
    5.  
    6.         int playerCount = PhotonNetwork.CurrentRoom.PlayerCount;
    7.  
    8.         // show the user's nickname
    9.         PhotonNetwork.LocalPlayer.NickName = Social.localUser.userName;
    10.         _nickname.text = PhotonNetwork.LocalPlayer.NickName;
    11.  
    12.         // show the user's avatar
    13.        // _userAvatar = Social.localUser.image.; // << doesn't work
    14.  
    15.  
    16.         if (playerCount != maxPlayersPerRoom)
    17.         {
    18.             waitingStatusText.text = "Wainting For Opponent";
    19.             Debug.Log("Client is waiting for an opponent");
    20.         }
    21.         else
    22.         {
    23.             waitingStatusText.text = "Opponent Found";
    24.             Debug.Log("Matching is ready to begin");
    25.         }
    26.     }
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    You are already setting the local player's NickName. This should get synced and you can show it for each player in a room.
    I assume you also got some string id for the avatar? You can store that in the Custom Player Properties via: PhotonNetwork.LocalPlayer.SetCustomProperties().
     
  3. MaciejKusztal

    MaciejKusztal

    Joined:
    Feb 4, 2020
    Posts:
    87
    After join to the room I would like to show the user nickname and after found the opponent show also his/her nickname. Important is connect the photon user's nickname with the google play games user's nickname. I tried to use this line to connect it. Is it okay?
    Second question how could I connect the opponent's nickname with the google play games opponent's nickname?
    Code (CSharp):
    1. PhotonNetwork.LocalPlayer.NickName = Social.localUser.userName;
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    Set the NickName before the client joins / creates rooms and it will sync the value. So in a Room, you can loop over all Players and show each user's NickName.