Room-Based Games
Room-based games are the most common multiplayer game type. Players join specific rooms (lobbies, matches, sessions) identified by names or codes. When a match ends, players leave the room.
What Are Room-Based Games?
Room-based games include:
- First-person shooters (COD, Valorant, Overwatch)
- Battle royales (Fortnite, PUBG)
- Party games (Mario Party, Fall Guys)
- Sports games (FIFA, NBA 2K)
- Competitive card games (Hearthstone)
- Any game with matchmaking lobbies
How Invitations Work
Invitation Flow for Room-Based Games
- Host creates a room - Room is created with a name/code
- Host sends invitation - Selects a friend to invite
- Friend receives notification - Shows who invited them and to what room
- Friend joins room - Directly joins using the room name/code from invitation
RoomInfo Data
Room information is stored in the RoomInfo model:
| Property | Description |
|---|---|
RoomId | Unique identifier for the room |
RoomName | Display name of the room (visible to players) |
HostId | User ID of the room host |
MaxPlayers | Maximum players allowed |
CurrentPlayers | Current player count |
IsPrivate | Whether the room requires a password |
CustomProperties | Game-specific metadata |
Configuration
Setting Up Room-Based Games
- Set
Default Game Typeon FriendManager toRoomBased - Configure
RoomBasedGameTypeSettingsif needed:- Default max players
- Allow room listing
- Room name constraints
Developer Details
RoomBasedGameTypeHandler
The RoomBasedGameTypeHandler handles all room-related operations:
// Create a room and prepare an invitation
_roomHandler.CreateSession("My Game Room", 4, customProperties, (success, roomInfo) => {
if (success) {
var invitation = _roomHandler.PrepareInvitation(
targetUserId: "friend123",
message: "Join my game!",
customData: null
);
// Send the invitation
}
});
// Handle incoming invitation to join
public void OnInvitationReceived(FriendInvitation invitation) {
_roomHandler.JoinSession(invitation.RoomInfo, (success, error) => {
if (success) {
Debug.Log("Joined room!");
}
});
}