Back to News for Developers

Building Your Multiplayer VR Experience

May 24, 2022ByNavyata Bawa

Multiplayer experiences have become an increasingly important part of the VR ecosystem. Multiplayer features make it easy for people to find, invite and play together in various games and apps. In this four-part “Building Your Multiplayer VR Experience” blog and video series, we’ll discuss the Platform SDK multiplayer features in Quest by exploring our open-sourced SharedSpaces sample made in Unity, and show you how to use the sample to build your own multiplayer app. If you're interested in learning by watching or listening, check out this video on the Meta Open Source YouTube channel.

In today’s blog, we'll go over the multiplayer features in the Platform SDK and what you can build with it. We’ll also go over the Unity SharedSpaces sample from App Lab and see these multiplayer features in action.

Multiplayer features

Quest multiplayer features—Destinations, Group Presence, Invites, Invite Link, Rosters and more—allow users to find, invite and play together in VR apps. These features enhance social interactions within your app and let your biggest fans invite others to join them, creating a unique multiplayer experience where players feel physically present with their friends in-app.

Destinations

Destinations are locations that people travel to within your app, and are essential to the multiplayer features in Quest development. The figure below shows three of the destinations from the SharedSpaces sample app. In our next blog, we’ll go over the steps to set up the destinations for your app.

Group Presence

Group Presence gives information about which app someone is in: if there’s a match, if they’re at a specific destination, if they’re joinable and much more. To learn more about destinations and group presence, visit our documentation about various use case scenarios and how they can be best used in your apps.

Deep Links

Deep links allow developers to direct users into a specific experience. Whenever someone launches your app to join a friend or navigates to a destination, the deep link includes information on the desired destination and any lobby or match.

The first step to enable a multiplayer experience is to integrate destinations, group presence and deep links. In our next blog, we’ll go over how to build your own version of the Unity SharedSpaces sample and how to set these up for your app.

Invite to App

Invite to App allows players to seamlessly invite Quest friends and Recently Played With users into existing lobbies using the Quest menu in supported games.

When you send an invite, a notification pops up to the invited person in VR and on the Oculus mobile app that invites them to join the experience.

To learn more about Invite to App APIs and how you can use them in your experience, visit the documentation page.

Invite Link

You can also use an Invite Link to launch into a Destination with a group of friends using the Oculus mobile app.

The Invite Link uses the Group Presence API to make sure everyone ends up in the same session. To learn more about Invite Link, visit the documentation page.

Roster

The Roster helps users view which friends are in-game with them. Users that are populated by the game are in the same lobby session ID when the current user’s presence has been set by the game. In the SharedSpaces sample, the roster is available by stepping on the roster panel. The image below shows an example of how the roster shows who is playing with you and who has been invited to join you.

Unity SharedSpaces Sample

Now that we’ve gone over a few Platform SDK multiplayer features, let’s take a look at a sample project called SharedSpaces that shows these multiplayer features in action. We will be looking at the Unity version of this sample; however, if you’re interested in the Unreal version, you can find it on App Lab.

First, let’s go over how the Unity SharedSpaces sample works. The sample uses three layers of networking:

  • Our Platform SDK, which allows us to set the destinations, presence, lobby and match.
  • Our transport layer, Photon SDK, which is responsible for the communication between the users who share a space.
  • Networking capabilities that are provided by Unity’s Netcode for GameObjects SDK.

The figure below summarizes the three layers that we discussed.

Installing the sample

Now that you have a basic understanding of how the SharedSpaces app works, you can download the Unity SharedSpaces sample on App Lab and try it out on your Quest headset.

Running the sample

Upon launching the app on your Quest headset, you’ll notice that you start in a room called Lobby. The player is represented by a colorful character that you can control using your controllers. The left controller moves the player around, and the right controller moves the camera around so that you can comfortably see the world around you and choose to go where you’d like. Pressing the Y button on the controller allows the player to jump.

A debug panel on the right lets you know the status of the destinations, the networking layer and information about who joins the room. On your left, you’ll see three private destinations that you can enter, and on the right you can see a public destination that you can enter.

On the top-left, you’ll see the option to invite friends to join you in this experience. This is the Invite to App feature that we discussed earlier.

On the top-right, you’ll see a roster, which shows information on group presence. This is the Roster feature of the Platform SDK in action.

Behind you, there is a paint shop where you have the option to change the color of your player. Alternatively, you can press the X button on your controller to change the color of your player.

On the bottom-left and bottom-right, you’ll see an option to query yourself and your friends to get more information about the players.

Sample test scenario

Now that you’re familiar with the space, try entering one of the destinations. The Purple Room is a public destination that anyone can enter and is reachable from any lobby. Now, let’s go back to the lobby.

Once you’re back in the lobby, try entering a different room. The Red, Blue and Green Rooms are private and need an invitation to enter.

Before you go into one of the private rooms, you can invite someone to join you. Go to the “Invite friends” panel to see the list of available friends and invite a friend from your list. Since you started the experience in the lobby, you are the master client of your lobby and you are hosting it.

A notification pops up that tells your invited friend that you have invited them to join you. If they accept the invitation to join you, you’ll see them in your Lobby. From now on, you both share the same lobby ID for this session.

You can now start a private match in the Blue Room. When you enter the Blue Room, you may see that your friend entered the Blue Room before you. Since they entered first, they are hosting the room, and you are connected to them. You also have the same match session ID that corresponds to the Blue Room. Now, if you leave the Blue Room, you both return to your lobby, since you share the same lobby ID.

If you had invited your friend while you were in the Blue Room, and they were in their own lobby, and they accepted your invitation, their match ID would have changed to the same match session ID that corresponds to the Blue Room, but their lobby ID would have been the same one that they had before. In that case, if you both left the Blue Room, you would have returned to your own lobbies, which would be different.

This was a quick walkthrough of the Unity SharedSpaces sample app. We went over some of the multiplayer features that Platform SDK has to offer and how these work in the Unity SharedSpaces app on Quest. In our next blog, we’ll go over how to build your own copy of this sample, including how to download it from Github and then build and run it on your Quest headset.


About this series

In this series, we discuss the Platform SDK multiplayer features in Quest by exploring our open-sourced SharedSpaces sample made in Unity. This blog is the first of a four-part series of blogs supporting the video series “Building your multiplayer VR experience.”

To learn more about the Platform SDK multiplayer features and how the SharedSpaces sample works, check out this Connect session that discusses building and growing multiplayer apps for Quest. Try out the Unity SharedSpaces sample by visiting App Lab and running it on your own headset. To learn more about how to use Platform SDK multiplayer features in your own apps, checkout our documentation for multiplayer features.

To learn more about Meta Quest, visit our website, subscribe to our YouTube channel, or follow us on Twitter and Facebook. If you have any questions, suggestions or feedback, please let us know in the developer forums.

To learn more about Meta Open Source, visit our open source site, subscribe to our YouTube channel, or follow us on Twitter and Facebook.