- Home /
Multipalyer for a Room based game
Hi,
So I am in the process of adding multiplayer to my game. The game itself is roombased, think Binding of Isaac. So the contains a large amount of rooms, the player can transition from one room to the other, and I want for other player to be present as well. I am at a bit of loss as to how to implement this. I thought about doing a custom server, because the logic itself is not that complicated, but I do not think that is feasible, so instead I am looking at using something like Photon.
My current problem is the approach to take. I am thinking that I should have many rooms per Master server and each room has a scene, this way player can transition from room to room and Photon is already geared to handling a lot of rooms.
So my questions are:
Is this a sensible approach?
Is it possible to precreate many rooms on Photon and if so how?
Whats an easy way to transition from room to room
Thanks for the help.
P.S I tried just joining another room from a scene with Photon, but this does not seem to work with something along the lines of
Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster.
Answer by tobiass · Jan 20, 2015 at 03:49 PM
You will have to make up an ID for each room (you will need this anyways to load a level). This ID can be the roomname for Photon. You don't have to create the room at all. Simply call JoinOrCreateRoom(string roomName, ...) and set the ID as roomName. The server will join you or create the room on the fly as needed. If anyone else gets in the room, this client will join. Done.
A drawback: The rooms are suited for a small amount of players. If your game becomes popular and everyone goes into the same room, then this room can be overcrowded and things might go wrong on weaker networks and platforms.
A solution to that would be to use your own room-ID as Custom Room Property. You can use those Custom Room Properties as filter for (random) matchmaking in JoinRandomRoom(). You basically check if a client can join a random room with the room-ID. If not, this client creates such a room, applies the room-ID as Custom Property and it can be found by the next player.
Again: No pre-made rooms needed.
In PhotonNetwork.CreateRoom() you can set the Custom Properties as part of a RoomOptions object. Also set roomOptions.customRoomPropertiesForLobby. See the API documentation PDF in the PUN package for details.
Well the problem with that is that I want each room to hold separate scenes I cannot coordinate this if the rooms are not precreated right?
There is a room-ID per scene. When you go through a door, you find out where it leads and load the scene and join the fitting room.
There is no state and no scene on the server - unless a room is in use. If a player goes to a specific place where no one else was, then the room starts from scratch.
Your answer
Follow this Question
Related Questions
Photon Networking create room issue 1 Answer
How to get all created rooms and join any one of them in PHOTON 2 Answers
Photon Private Room Help 0 Answers
Join room and create if not existing. 0 Answers
Why doesn't this work 2 Answers