The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

How to use Join random room with filter

VictorChildishK
2017-01-08 18:28:09

I have two working maps that i want users to be able to join , however i am currently using joinRandom so users just join rooms they are not supposed to join.
Can you please help me with a simple script that only uses the max players as a filter because one map should have only 2 max players and the other 4

I am building using the DemoVoice-push to talk scene...the one with the baby and teddybear looking characters showing how to use photon voice (max 4 players)

and the other scene was built using the punBasics scene from the photon realtime (max 2 players)

Please help me

Comments

JohnTube
2017-01-09 09:40:41

Hi @VictorChildishK,

You need to use the proper JoinRandom method that sets the expected MaxPlayers:

void JoinRandomRoom(byte expectedMaxPlayers){  
    PhotonNetwork.JoinRandomRoom(null, expectedMaxPlayers, MatchmakingMode.FillRoom, TypedLobby.Default, null);  
}

Do not forget to set MaxPlayers value when you create rooms:

void CreateRoom(string roomName, byte maxPlayers){  
    RoomOptions roomOptions = new RoomOptions();  
    roomOptions.MaxPlayers = maxPlayers;  
    PhotonNetwork.CreateRoom(roomName, roomOptions, TypedLobby.Default);  
}

mahmoud93p
2018-02-27 15:44:51

if you want just joinRandomRoom with 1 condition "Maxplayers"
you can use this

void JoinRandomRoom(byte MaxPlayers_) { PhotonNetwork.JoinRandomRoom(null, MaxPlayers_); }
Back to top