question

zelofi avatar image
zelofi asked

How to have my ID show on my player but on other players it's their ID? (Unity/Photon)

I'm currently working on a system where the player has their PlayFab ID show up on their head, and for the most part it's working, however, if they check my player, it shows their ID instead of mine. Is there any way to check the views of the players and have it so that it shows their PlayFab ID instead of mine?

Here's the script:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using PlayFab;
 using PlayFab.ClientModels;
 using TMPro;
    
 public class PlayfabIDShow : MonoBehaviour
 {
     public TextMeshPro playfabID;
    
     private void Start()
     {
         GetAccountInfo();
     }
    
     void GetAccountInfo()
     {
         GetAccountInfoRequest request = new GetAccountInfoRequest();
         PlayFabClientAPI.GetAccountInfo(request, Success, Fail);
     }
    
     void Success(GetAccountInfoResult result)
     {
         playfabID.text = result.AccountInfo.PlayFabId;
     }
    
     void Fail(PlayFabError error)
     {
         Debug.LogError(error.GenerateErrorReport());
     }
 }
Player 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.

1 Answer

·
Simon Cui avatar image
Simon Cui answered

The GetAccountInfo API method by default gets its own account infomation for the current logged in player unless you specify another PlayFabId in the request body. But since the PlayFabId is what you need to display, it is not the right way to achieve it. The PlayFabId can be obtained using PlayFabSettings.staticPlayer.PlayFabId instead of using GetAccountInfo. You can send your own PlayFabId to other players through Photon, then other players can use this PlayFabId to display.

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.