How to show different medals for different players on the same canvas?

Hi,

This may be a tad unusual but I’m making a tournament format multiplayer game and I’ve made a canvas with images that are filled with gold, silver and bronze medals if a player finishes 1st, 2nd or 3rd.

The canvas is not a child of any objects and has a don’t destroy on load function on it because I need it to carry the placement info and show the medals to each player individually throughout all levels of the tournament.

If a player finishes 1st, 2nd or 3rd, that player sends an RPC (Photon) if Photonview is Mine - to the canvas telling the canvas which number level and which color medal that player should see: Example :

    [PunRPC]
    void GoldMedalShow3()
    {
        GameObject medalCanv = GameObject.Find("TourMedalCanvas");
        medalCanv.GetComponent<Transform>().GetChild(2).GetComponent<Image>().sprite =      Resources.Load<Sprite>("goldMedal") as Sprite;
    }

This finds the canvas and assigns a gold medal on the third sprite image, meaning the player won the third level (0 is the first so it’s the third on GetChild(2))

I then RPC it:

GetComponent<PhotonView>().RPC("GoldMedalShow3", PhotonTargets.All);

However ONLY that player should see his medals and not the others and vice versa. This doesn’t work with multiple players. Nothing happens.

I also tried activating the canvas only if photonview is mine and turn if off on else, but that turned off the canvas for both players (all players) with this code:

void Start () {


    if (photonView.isMine)
       {
          
            GameObject TourManager = GameObject.Find("TourCrownCanvas");

            TourManager.SetActive(true);
        }
        else
        {
           
            GameObject TourManager = GameObject.Find("TourMedalCanvas");

            TourManager.SetActive(false);
         }
}

Does anybody know what I’m doing wrong and how I can display what each payer has won individually on a “shared” canvas that is not a child object of any players and is not instantiated since it has to remain active throughout the whole tournament with DontDestroyOnLoad? I want to avoid making separate medal canvases for each player because it would require separate scripts and a lot of re-coding, so that is an absolute last resort. All help is greatly appreciated thanks :slight_smile:

It could be possible that you are checking photonView.mine before it could be instantiated. So try putting it in Update() inside a if condition.

There is another alternative but would add to your coding efforts.
You can try providing IDs to each player. And while sending a message from server ensure to send the player-id . If the player-id sent by server and the client’s id is same, TourManager.SetActive(true) . If not matching then TourManager.SetActive(false)

1 Like

Awesome idea with the ID’s. I’ll try it out thank you for your help