Getting Started with Shared AR

Creating a Shared AR experience involves a few basic initial steps. You’ll need to do the following:

  • Set up ARDK networking in your project. Networking is used for communicating with the ARDK backend (for localization data and session management) and for network messaging between clients in the same Shared AR session.

  • Set up AR localization so each client can localize and synchronize to the same real-world space.

  • Add your game objects and logic, using HLAPI or LLAPI to coordinate communicating game object positions and other data between clients.

Set Up ARDK Networking

Adding networking to your project can be done via ARDK managers, or by using the LLAPI networking setup APIs.

If you want to use ARDK managers, add an `ARNetworkingSceneManager` prefab to your scene. This prefab contains all the necessary ARDK components to enable networking and AR localization. Once you add the `ARNetworkingSceneManager`, do the following:

  • Make sure that only the ARNetworkingManager and CapabilityChecker components have “Manage Using Unity” enabled. The other components will be managed by the ARNetworkingManager component.

  • Fill in the Session ID (in the UI, this is the Network Session Manager component’s “Session Identifier” field). It can be whatever you want as long as it’s not empty.

  • Delete any default camera in your scene. `ARNetworkingSceneManager` also adds a child ARSceneCamera that you should use as the camera for your scene.

See the Pong and PongHLAPI demo scenes in ARDK-Examples and Tutorial: Pong - Creating a Multiplayer AR Game for examples of using ARNetworkingSceneManager.

If you can’t use ARDK managers, you can enable networking by creating your own IARNetworking instance and configuring your ARSession. For details on this, see Setting Up a Networked AR Session.

Note

Each client that wants to join the same shared ARDK network session must also be configured to use the same API token. To understand how to set the API token in your app, see Authentication.

Set Up AR Localization

Shared environment AR localization is automatically enabled when your `ARNetworkingSceneManager` is enabled. If you’re managing your own networked ARSessions and not using ARNetworkingSceneManager, you should enable `IsSharedExperienceEnabled` in your session’s `ARWorldTrackingConfiguration`.

You’ll need to decide which localization method you want to use. You can localize by using an object in the environment (shared environment localization), or localize using a marker image, like a QR Code (MarkerSync localization).

In both cases you’ll need to add code to manage AR localization state. You’ll instruct your user to point their device camera at the desired localization target and monitor `PeerState` to determine when your client has successfully localized. For details on this see:

Use HLAPI or LLAPI to Share Game Object Information

Once your client has successfully localized, you can start sharing game object information. You’ll use either the High-level API (HLAPI) or Low-level API (LLAPI) to send messages between clients.

See Sharing Virtual Object Information for more details on these APIs and when to use them.

Walkthrough of Developing a Shared AR Experience with ARDK

The following video walks you through creating a shared AR experience in Unity. The video demonstrates how to add ARNetworking, scanning the environment to localize, and more: