How to implement Cross-Platform Multiplayer

AccelByte Inc
5 min readFeb 9, 2021

--

AccelByte’s Anggoro Dewanto explains how to implement cross-platform multiplayer using sample code from AccelByte’s sample game and backend.

Written by: Anggoro Dewanto

Multiplayer, the feature that will extend your game’s lifetime and give players endless possibilities. If you’ve designed your game for multiplayer play, that’s great! Even if you haven’t, adding online features will only benefit your game.

With the rise of countless game platforms and storefronts, you can embrace the diversity of platforms by implementing cross-platform multiplayer features. Doing so will enable you to reach as many player bases as possible. As long as you are committed, there are many ways you can accomplish this goal without redesigning your game from scratch, nor maintaining different builds and online services for each platform.

This article will show how you can implement cross-platform multiplayer in a Unity game by leveraging AccelByte’s platform. AccelByte’s backend services will be the centralized place where the game’s online features live, therefore freeing game developers from platform-specific restrictions.

Let’s get into it.

Overview

When people talk about cross-platform they’re usually referring to crossing the wall between consoles and PC, but in this article we specifically give examples of enabling cross-platform between a game publisher’s own platform (let’s call this AccelByte) and Steam. However, the same techniques can also be used to enable cross-platform play between consoles.

AccelByte and Steam builds connecting to same AB Services

If you want to see the code applied to a real Unity game, head to AccelByte’s Github where we’ve shared our Unity sample game, Light Fantastic. Note that in order to actually make calls to AccelByte’s demo environment, you will need to request an account from us at hello@accelbyte.io.

Account

First we have to know who the player is, meaning that we need to authenticate them. Each platform will have their own account system, but cross-platform means your game needs to recognize a user wherever she plays your game.

AccelByte and Steam account linking

Users from Steam will play the game from Steam’s launcher, therefore using a Steam account, while others will play the game from the AccelByte Launcher by using an AccelByte account.

LightFantastic on Steam
LightFantastic on AccelByte Launcher

Using the Account Management feature in AccelByte’s platform, we can unify different platform accounts into a single account, so that users can come from different platforms, or even multiple platforms, and the game can recognize them all. This is what we call account linking.

In the AccelByte platform configuration, we support account linking for many different platforms. In this example, we’ve already set up integration with Steam.

Steam integration on AccelByte admin dashboard

Doing so enables us to recognize when a user authenticates using a Steam or AccelByte account. A user can even have both accounts linked, so that she can play from either platform.

Linked user account (Steam) on user interface

By integrating the AccelByte Unity SDK in the game client, there’s no difference between the Steam and AccelByte platform builds. The only difference is that we use an additional runtime parameter when launching the game from Steam’s launcher.

The AccelByte Unity SDK is integrated by dropping it into the game project, like so:

AccelByte SDK in LightFantastuc project structure

And from the game code itself, we handle the user authentication by:

Full logic code can be accessed on this GitHub page.

Since both platforms are OAuth2 compatible, the authentication UX will be roughly the same:

Therefore, adding more platforms to link to will use a similar process.

Multiplayer

Now that we have a game that’s able to recognize its users properly, we can leverage the unified accounts to let them play together, cross-platform.

It doesn’t matter if your game is P2P or using an authoritative server, you will need a way to get players together. AccelByte’s sample game uses an authoritative server per match that is managed by AccelByte’s platform.

Chatting and forming parties are two of the most basic multiplayer features. So we enable players to chat and create parties by connecting to AccelByte’s social services.

Lobby (full logic code):

Party (full logic code):

Chat (full logic code):

Party chat example in LightFantastic game
Party match example in LightFantastic game

The meat of a multiplayer game is of course playing together with (or against) others. By enabling matchmaking from AccelByte’s admin interface, we can let game clients request its users to be matched together.

Matchmaking configuration in AccelByte admin dashboard

Matchmaking (full logic code):

The match in LightFantastic sample game

Anggoro Dewanto is the Director of Engineering at AccelByte, a one-stop-shop for live game services.

--

--

AccelByte Inc
AccelByte Inc

Written by AccelByte Inc

One Stop Shop for Live Game Services | 🏙️HQ: Seattle | 🏢 Team: Vancouver, Yogyakarta, and global