Room full and disappearing players

Options
Hi,

In my game I have set maxPlayers = 10 to each room players can be in.

RoomOptions roomOptions = new RoomOptions() { isVisible = false, maxPlayers = 10 }; PhotonNetwork.JoinOrCreateRoom("MyGameRoom", roomOptions, TypedLobby.Default);

My game is adventure game and there are many physical rooms, players can move from one room to another and see each other. Each room can have 10 players at a time. This way the rooms don't get too crowded and game too slow. But what about when more than 10 people are trying to fit in the same room? Is there some way when player fails to get in the room because it's full Photon would create "MyGameRoom2". It would be like another dimension of the same physical room in the game.

RoomOptions roomOptions = new RoomOptions() { isVisible = false, maxPlayers = 10 }; PhotonNetwork.JoinOrCreateRoom("MyGameRoom2", roomOptions, TypedLobby.Default);

So all the new players that don't fit in "MyGameRoom" would start to go in the "MyGameRoom2". Right now when player enters a room that has more than 10 players already he/she is alone in it. Could this be done?

Another question is when player disconnects or something happens the player just disappears from the game. Could I somehow make an particle FX instance when this happens? So other players still playing would see this particle FX instead of player just disappearing?

Comments

  • Hi @Kapteeni,

    there is a callback notifying a user that joining the room has failed: void OnPhotonJoinRoomFailed(object[] codeAndMsg) { // codeAndMsg[0] is short ErrorCode. codeAndMsg[1] is string debug msg. }. You can use this one in order to try to connect another room.

    To the second question: if the player disconnects by choice, you can either use RPC or raise an event in order to notify other clients before actually leaving the game. Using one of those you can send the position, the other client should use to instantiate a local ParticleSystem. If the client gets disconnected by connection loss or something similar, things get a little more tricky. There is another callback notifying each client in the room that a certain client has left the room: void OnPhotonPlayerDisconnected(PhotonPlayer otherPlayer) { ... }. In my tests this callback is called before the actual object gets destroyed, so you might use it to find the certain object and instantiate a ParticleSystem at its position. This might look like the following and should also work if the client disconnects by choice:
    public void OnPhotonPlayerDisconnected(PhotonPlayer otherPlayer)
    {
        foreach (PhotonView pv in FindObjectsOfType<PhotonView>())
        {
            if (pv.ownerId == otherPlayer.ID)
            {
                // if the client has multiple objects instantiated you need a second condition (e.g. Tag)
    
                Vector3 position = pv.gameObject.transform.position;
            }
        }
    }