How to create a squad/party system and join a game together?
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 create a squad/party system and join a game together?
jacobfdunbar
2020-07-10 13:29:18
We're introducing a new squad/party feature to our game and are having trouble conceptualizing how to do matchmaking with groups of players. The new mode will have teams of 2 to start, with up to 10 teams joining a game. My current idea for how to implement this is as follows:
- Join both players to a special, private room with a max player count of 2.
- Have the party leader begin a search for a true game room, stating that they'll need 2 opens spots and passing the other player as an "expected player."
- One the party leader finds the room, communicate the room code to the other player so that they may join as well.
However, the issues that I think are present with this solution are:
- When players are joined to a room they can't actively search for other rooms since they're connected to the game server, not the master server
- Once the leader joins the actual game room they'd lose any method of quickly informing their group mate of what room to join (No RPC or changing of Room Properties since they're no longer in the same room)
Are these issues true? Any ideas about how to navigate around them? I know you can do outside-of-room communication between players using Photon Chat but ideally we're trying to stick with just PUN. Thanks for any help!
Comments
Did you ever figure out a solution? These are problems I'm trying to research, as well.
jacobfdunbar
2021-03-05 15:13:29
Hey @Cbun! We ended up solving this using PlayFab, so if your project is using PlayFab you can check out a brief summary of that solution at the bottom. Otherwise I think your best options are either to use Photon Chat (additional costs) or a janky method of leaving/rejoining rooms.
Janky Room Solution
Theoretically you have all party members join a room together, then when queuing up for a game have the master client disconnect to search for a game in the lobby. When searching the master client would use a list of the names of the other expected party members to find a room with enough space. Once found, the searching player would note the room ID of the found room, leave to reconnect to the party's room, inform them all of the found room ID, and then have each player rejoin the found room. A lot can go wrong with this setup though as this whole process would take a couple seconds. The found room might fill up in that time, party members might disconnect, etc. The regular game rooms would also need to be open/joinable by ID, which could be a security vulnerability. Not sure I'd recommend this route, but it could work with lots of error checking and an understanding of the risks.
Our PlayFab Solution
Our project used PlayFab so we ended up using temporary PlayFab Groups to represent the parties. Basically any player that sent an invite would create a party (group) and be assigned as its leader. Any other members joining would be added as members to that group and we used the shared group data to pass information about the players and party: equipment list/name for each player to display that player in our "lobby" and the Photon room code once a game was found. The caveat with this method was we only wanted to update the group data at fixed intervals to not use too many PlayFab API calls, so there's upwards of a 3 second delay that you need to account for when doing actions with a party.
jacobfdunbar
2021-03-05 15:21:09
Hey @Cbun, unfortunately no great solutions only using Photon other than Photon Chat from what I've found.
Our team was using PlayFab so we implemented a crude system using PlayFab Groups. Basically a player sending a party invite would create a PlayFab group and be assigned as the leader. The Group's data would be updating periodically to include information about the other players in the group (for displaying those players in the "lobby") as well as information about the Photon game room once one was found.
In theory you could implement a system where the party members all join a party room together, then the leader leaves the room temporarily to search for an actual game room. Once found, the leader would disconnect, rejoin the party room, and inform everybody about the found room. At that point everyone would use the found room's code to join it, but there's a lot of problems that could arise with this solution that I'm not sure I'd suggest it. Because this process would take a few seconds the game room could fill up, party members could disconnect, etc. within that time.
Hi @jacobfdunbar, @Cbun,
This is a bit late but nevertheless I wanted to add a detail:
team or party members can guess the room name of the team / party leader using FindFriends (polling) as we explain in the docs here.
Back to top