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.
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.
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 email@example.com.
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.
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.
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.
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.
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:
And from the game code itself, we handle the user authentication by:
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.
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):
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 (full logic code):
Anggoro Dewanto is the Director of Engineering at AccelByte, a one-stop-shop for live game services.