Search Unity

Third Party [PUN] Looking for Rpc clarification for lobby - doing something wrong

Discussion in 'Multiplayer' started by MrLucid72, Jan 3, 2017.

  1. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    988
    So the UI has a list of players. Let's say it defaults to say "0" for the # of players.

    Whenever a player joins the lobby, I want EVERYONE's UI to also read numOfPlayers++.

    So the master client (M) joins, total players 1.
    Another client (C) joins, total players 2.

    Right now, I'm trying this (and it doesn't seem to work):

    Code (CSharp):
    1. public override void OnJoinedRoom()
    2. {
    3.     base.OnJoinedRoom();
    4.     RpcUpdatePlayerUI();
    5. }

    Code (CSharp):
    1. [PunRPC]
    2. void RpcUpdatePlayerUI()
    3. {
    4.     int playerCount = PhotonNetwork.room.PlayerCount;
    5.     playerCountTxt.text = playerCount.ToString();
    6. }

    Results:
    M = 1
    C = 2

    My guess is that C wasn't a master client, so it didn't have permission to Rpc to the others, so it only assigned itself.

    So with UNET, I could just [Command] to talk to the host to Rpc to others. How would I do the equiv. in Photon?
     
  2. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    988