How to use Join random room with filter
The whole answer can be found below.
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).
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
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_);
}