I am using Photon Cloud with My Unity Game Projects.
Photon Plugin is Integrated and Working, I am able to Join and Create Rooms, but I am curious about the Private Rooms.
I read somewhere on the Photon ExitGames Website you can create Private Rooms, but I could Not find any documentation on how to enable Creating Private Rooms.
Is Private Rooms only Feature for Dedicated Photon Servers, or can this be done using Photon Cloud?
If so, what script do I need to add to Enable the Private Rooms in my Main Menu Lobby?
This is what my Photon Code Looks Like (Join Room and Room Listing)
Seems I am missing the Join Room Code in there, as my Photon was modified previously by a Developer I was working with, so I’ll need to add back the Option of Join Room, or Replace Random Join with Join Room (I think I prefer that)
Then I need the actual Line of Code Needed to don’t list any Room Name that StartsWith(“PRIVATE_”), as you stated.
Sorry, I am not programmer, but I can get things working by going in and playing with it lol… So if you can assist with fixing my code! Would be Awesome!
I’m sure maybe this Question may come up for others eventually. = )
You can hide private rooms from the lobby listing and they will not be used in random matchmaking either.
When you create a room, just set the “visible” option to false.
You have to make sure another user will know your room’s name or else your private players will stay alone forever. On the other hand, knowing the room’s name is then as good as knowing a password.
If the rooms are invisible, you can also keep on using random matchmaking, which is the preferred way to find games. It avoids issues that would arise when many clients try to join the same room cause it’s first in the list. Let’s say your room has space for just 2 players and 4 try to join the first room listed. Then 3 are rejected which is not too good.
Hope this helps. Let me know if anyone needs details.
since i’m not much of a programmer, can you explain alittle more in detail such as provide the exact line of code needed to set this up? the part where you said "When you create a room, just set the “visible” option to false. "
I can only help with C# code but JS should be very similar. Hope this helps:
Somewhere in your code are calls to CreateRoom. There are several variants of this same method with more or less parameters.
One is defined as: CreateRoom(string roomName, bool isVisible, bool isOpen, int maxPlayers)
So, to create an invisible (private) room for up to 4 players you could call:
PhotonNetwork.CreateRoom(roomNameAllPlayersKnowAbout, false, true, 4);
The variable roomNameAllPlayersKnowAbout must be a string your players know. Don’t set isOpen to false, or else no one can join. You can replace 4 with any number that fits your game or 0 for “no limit”.
It’s more traditional for the password protected room to be visible to the player. The player clicks it, is prompted for a password, and then allowed to join if the password is correct.
One way to accomplish this is for the server to hash its password with SHA256 or whatever, and include the hashed password in the room’s properties. The client computer can use this hash to verify the client’s password is correct before allowing him to connect to the server.
For a little more security, the server can re-verify the password on player join, and kick the player if it’s incorrect. It’s still not hack-proof, but it’s no worse than a hidden room that can be guessed.