Multiplayer with PlayFab
Multiplayer is be a great addition to many titles, and PlayFab provides several services focused on multiplayer scenarios:
|Leaderboards||Track and respond to player activity with statistics and leaderboards||PlayFab essentials|
|Entity Groups||Create permanent or temporary groups of players and signal activity.||PlayFab essentials|
|Matchmaking||Deploy custom matchmaking rules to group players quickly||PlayFab essentials|
|Party||Connect players with networking and accessible in-game chat||Premium Service|
|Servers||Dynamically scale custom multiplayer servers in Azure||Premium Service|
Leaderboards, Entity Groups, and Matchmaking are offered in PlayFab Essentials, our core services package, without any additional cost. Servers and Party cost extra (see Multiplayer Server billing and Party billing).
While titles can use all of these services in combination, they can be used independently as well, and this is quite common. For example titles might use PlayFab matchmaking but allocate servers from an alternative multiplayer server hosting solution. Or games might use PlayFab multiplayer servers for hosting, but use their own matchmaking system to bring players together.
Increasingly games are building cross-network experiences with players engaging each other from different identity domains (e.g. Xbox Live players interacting with Steam players interacting with custom identity systems). PlayFab's services were designed to support cross-progression and cross-network play.
Example multiplayer scenarios
PlayFab is designed to support a variety of multiplayer modes. Below is a list of modes that might be integrated in a single, fairly sophisticated title. In this section we will briefly suggest how to implement these experiences using PlayFab services.
|Game Mode||Max # of Players||Leaderboard||Matchmaking||Backfill||Invite friends||Unsolicited join-in-progress||Chat||Server Model|
|Casual small sessions||8||Yes||Yes||Yes||Yes||Yes||Yes||P2P|
|Casual large sessions||32||Yes||Yes||Yes||Yes||Yes||Yes||Cloud Server|
|Competitive small sessions||8||Yes||Yes||No||Yes||No||Yes||Cloud Server|
|Competitive large sessions||32||Yes||Yes||No||Yes||No||Yes||Cloud Server|
Leaderboards and player data
In-game leaderboards can be used to:
- Store player results to trigger in-game rewards and other gameplay behavior
- Store and rank player results as a matchmaking input
- Create in-game ranking experiences, where users can browse the leaderboard and understand their comparative performance
Leaderboards can augment both single-player and multiplayer modes. For example a campaign leaderboard might track the number of special items collected by the player, while a multiplayer leaderboard might track player vs. player competitive wins. PlayFab leaderboards is built to power these experiences, tracking a player statistic and ranking players using that statistic.
If player results do not need to be shared broadly with other players, player-associated PlayFab Entity data may be better suited to store this data. A benefit of PlayFab's Entity system is the ability to track cross-network progression of player's activity and other data across multiple accounts. Changes to PlayFab leaderboards and data both fire PlayStream events which can trigger custom CloudScript. This allows for highly customizable responses to player activity in real-time.
In-game parties and unsolicited join-in-progress
Players often want to commiserate outside of proper gameplay and your title may support this through an in-game guild or party experience. PlayFab Entity groups and PlayFab Party are designed with these scenarios in mind.
You can make a PlayFab Entity group for:
- Players sharing status with their followers
- Players creating guilds that are long-lived (months or days)
- Players creating parties that are short-lived (hours or less)
PlayFab Entity groups have built-in flows for controlling access and players requesting group access from the group's leaders. Groups can be associated with arbitrary file data, so you can allow players to share messages or post other persistent content to a shared space.
While you can use Entity groups for signaling and other slow data-sharing, PlayFab Party is best suited for real-time data transfer and chat. A common usage of PlayFab Entity groups will involve players storing PlayFab Party network descriptors or PlayFab multiplayer server session details to the group's data storage. This sharing of session information can allow players to join a friend's session unsolicited. If you are using non-PlayFab services for real-time communication or game hosting, those systems typically have identifying information that you can similarly signal between players using Entity groups.
PlayFab Entity groups does not have a push notification system for players to be notified of Entity object changes and requires polling the service to keep updated. Platforms may provide built-in invitation and presence systems that launch toasts and have other beneficial experiences (join in progress from the player profile card) that you should consider integrating if applicable.
Matchmaking and backfill
Players may want to play with new people they don't know, and balanced anonymous matchmaking experiences are core to many multiplayer games. PlayFab Matchmaking is designed to get players together quickly using rules you customize.
When a player or group of players want to play together, one player creates a matchmaking ticket for themselves or the entire group. PlayFab Matchmaking allows users to be submitted to matchmaking together as a team, with a join flow that ensures that all players in the group consent to match together. The service also allows for backfill tickets, which can be used to replace players who leave mid-game. Join in progress and backfill capabilities are helpful mechanisms to keep casual game sessions as full as possible.
PlayFab Matchmaking is integrated with PlayFab Multiplayer Servers to simplify server allocations for completed tickets and improve match security. Also PlayFab Matchmaking tickets fire PlayStream events that can trigger CloudScript, this can help integrate matchmaking with your own multiplayer systems.
PlayFab Party be used to add real-time voice and text chat to social or gameplay experiences for up to 32 players. PlayFab Party enables a player's presence in multiple networks simultaneously, with customized muting rules for each network. This provides flexibility to implement channels and complex chat relationships.
Party utilizes Azure Cognitive Services to transcribe player voice chat and synthesize text as speech. This functionality has several uses, but was primarily designed as an accessibility aide. Party not only transcribes player chat, but also translates chat in real time. In anonymous matchmaking and international competitive games, these transcription and translation capabilities make for a more engaging multiplayer experience.
Real-time multiplayer games typically select a specific player device to host game state (aka "peer to peer") or use a dedicated multiplayer server. If hosting a game on a player device, PlayFab Party is an ideal low-latency device-to-device networking system to synchronize this game state across the session's participants.
It is difficult to scale peer to peer games when the device count grows. While PlayFab Party provides network encryption and uses relays to protect player IP addresses, having a device operate as host still opens avenues for cheating.
PlayFab Multiplayer Servers provides simple and efficient scaling of multiplayer across Azure's global cloud. Using a small server, for example loading 10 sessions of 10 players each on a F2v2 Linux virtual machine, can efficiently and dramatically simplify your multiplayer design and improve it's reliability compared to a P2P implementation. Sophisticated multiplayer computation can be achieved by setting a server's build configuration to allocate more Azure resources to a session, perhaps using 8 or more cores for a 200 player experience.