Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

RoomList & players

Discussion in 'Connected Games' started by mimat18, Jul 16, 2019.

  1. mimat18

    mimat18

    Joined:
    Feb 16, 2019
    Posts:
    12
    Hi ... I don't know how to get the RoomList and the number if players on the room . I tried to use the functions but i had some errors and had no result .
    Any one please can help me and give me a simple example about how to use it .
    I am using photon pun 2 .
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,335
  3. Livindaki

    Livindaki

    Joined:
    Jun 13, 2017
    Posts:
    37
    ok let me so ask you please about RPC
    public override void OnJoinedRoom()
    {

    Debug.Log("4-State is: " + PhotonNetwork.NetworkClientState.ToString());
    parents = PhotonNetwork.Instantiate("My_View", new Vector3(0, 0.5f, 0), Quaternion.identity, 0);
    parents.transform.SetParent(source.transform);
    pv = parents.GetComponent<PhotonView>();
    if (pv.IsMine && Load_Rooms.Player_Name=="tamim")
    pv.RPC("Reg_Room", RpcTarget.OthersBuffered, Load_Rooms.ClientRoomName, Load_Rooms.ClientRoomSize, Load_Rooms.ClintRoomPassword, Load_Rooms.ClientRoomCoast, Load_Rooms.MasterConfirmCode);
    Debug.Log("Name: " + Load_Rooms.ClientRoomName + " Password: " + Load_Rooms.ClintRoomPassword + " Confirm: " + Load_Rooms.MasterConfirmCode);
    }
    [PunRPC]
    public void Reg_Room (string RN,int RS,string RP,int RC,string MCC)
    {
    Debug.Log("5-State is: " + PhotonNetwork.NetworkClientState.ToString());
    if (Load_Rooms.ClientConfirmCode == MCC)
    {
    Load_Rooms.ClientRoomName = RN;
    Load_Rooms.ClientRoomSize = RS;
    Load_Rooms.ClintRoomPassword = RP;
    Load_Rooms.ClientRoomCoast = RC;
    Create_Room_Is_OK = true;

    PhotonNetwork.LeaveRoom();
    }
    }
    .doesnt work ; the variables on the clients doesnt change ... why ?
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,335
    I'm sorry but I can't debug your code and don't see the problem without that.
    In cases like this: Try to scale back and try to implement a minimal case to check what's working and what isn't.
    The Basics Tutorial could be a good guide for starters. Read and code along. It uses RPCs, too.
     
  5. Livindaki

    Livindaki

    Joined:
    Jun 13, 2017
    Posts:
    37
    Ok NP.
    in a case that i have create a room and entered the room .. and i have a Variable X for each player .. i want to change for every player enter room the value of X .
    i cant do that . cause i am new on multiplyer programming :-(
     
unityunity