ARDK Document "How to Use Shared AR"

  • Issue category: Shared AR / Multiplayer / ARDK Documentation / Networking / VPS
  • Device type & OS version: Android / iOS
  • Host machine & OS version: Mac / Windows / Linux / Other Ex. Mac on Big Sur x.x
  • Issue Environment :
  • Xcode version:
  • ARDK version: ARDK 3.0
  • Unity version: 2022.3.16f1

Hello? Thanks to your help, I think I’m having a great day today.

I don’t know what to do in “How to Use Shared AR” to “Using Shared Space Manager with the Coverage API”. More specifically, “1. Instantiate a copy of Niantic.Lightship.AR.CoverageClientManager:” in “Using TryGetCoverage to get AreaTargets” is difficult. Where should I make a C# script and instantiate it?
If I have any shortcomings in asking questions, I’m sorry and I’ll fix it if you tell me.
Please help.

Thank you in advance :slight_smile:

Hello jhpark135,

You will need to do three things which will be detailed below. If this does not work for you please let me know.

Ⅰ : Create a script called CoverageClientSelector with the code sample provided.

  • In the Assets folder, create a script called “CoverageClientSelector”. Once you have the script open, navigate to How to Use Shared AR | Niantic Lightship, and then scroll down to the **Using TryGetCoverage to get AreaTargets **section. From there, copy the code sample at the bottom of the section and paste it into your **CoverageClientSelector **script. Be sure to save the script before exiting.

Ⅱ : Create a Dropdown menu.

  • In the Hierarchy, Create UI → Legacy → Dropdown.

Ⅲ: Create a CoverageManager and add the necessary Components.

  • Create an **Empty Gameobject **in the Hierarchy name it “CoverageManager”. Select the CoverageManager Gameobject you’ve just created and click “Add Component”. You will want to add both the “Coverage Client Manager” script and the “Coverage Client Selector” script.
  • In the “Coverage Client Selector” component, select the respective objects you’ve created in the previous steps for both “Coverage Client” and “Dropdown Selector”.
2 Likes

thank you for your response!! I’ll try that^^

I’d like to ask you what level of shared AR performance is.

  1. Whether the movement of the AR character is the same for players 1, 2
  2. Is the bullet shot by player 1 visible to player 2

Shared AR is integrated on top of Unity’s existing Networking and AR systems. However, you still need to manually set up the networking for the things you mentioned. For further details, I recommend looking into Unity’s networking documentation for handling object spawning and tracking.

Additionally, You can follow the steps listed here under the sections titled “**Installing the ARDK Plugin” **to install ARDK 3.3.

I got stuck doing the [Joining a Room using SharedSpaceManager] step after going through the method you told me. Please help. I’ll tell you what I’ve done so far after the method you told me.

1. Instantiate a copy of the SharedSpaceManager.

    1. Adding SharedSpaceManager Components:
    • Added the SharedSpaceManager component to XR Origin.
    1. Refer to SharedSpace Manager in Script:
    • Make the script MySharedSpaceController the name of the script that you want to implement the shared AR-related features. Declare a reference to ‘SharedSpaceManager’ in this script and link it in the Unity Editor.

[SerializeField]
private SharedSpaceManager _sharedSpaceManager;

2. Prepare and participate in a shared AR session to the selected location

The code for preparing and participating in a shared AR session using the ‘Default Anchor’ in the location selected by the user is as follows:

private void OnLocationSelected(string defaultPayloadToSet)
{
// Create VPS Tracking Options
var vpsTrackingOptions = ISharedSpaceTrackingOptions.CreateVpsTrackingOptions(defaultPayloadToSet);

// Create Room Options
var roomOptions = ISharedSpaceRoomOptions.CreateVpsRoomOptions(
vpsTrackingOptions,
“optionalPrefixForRoom_”,
10, // Maximum number of participants
“Room Description Here!”); // Room Description

// start Shared AR session
_sharedSpaceManager.StartSharedSpace(vpsTrackingOptions, roomOptions);
}

This code is an example of the ‘OnLocationSelected’ method, which should be called when selecting a location in Dropdown. Use the ‘DefaultAnchor’ at the selected location to set up the VPS tracking and room options and forward them to the ‘StartSharedSpace’ method in the ‘SharedSpace Manager’ to initiate a shared AR session.

3. Update event listener settings and participation status UI

Set up a status-changing event listener for ‘SharedSpaceManager’ and provide users with a UI to participate as hosts or clients based on their tracking status:

[SerializeField]
private Button _joinAsHostButton;
[SerializeField]
private Button _joinAsClientButton;

protected void Start()
{
_sharedSpaceManager.sharedSpaceManagerStateChanged += OnColocalizationTrackingStateChanged;
}

private void OnColocalizationTrackingStateChanged(SharedSpaceManager.SharedSpaceManagerStateChangeEventArgs args)
{
if (args.Tracking)
{
_joinAsHostButton.gameObject.SetActive(true);
_joinAsClientButton.gameObject.SetActive(true);
}
}

4. Join as a host or client

Add a listener to the button so that the user can participate as a host or client:

protected void Start()
{
_joinAsHostButton.onClick.AddListener(OnJoinAsHostClicked);
_joinAsClientButton.onClick.AddListener(OnJoinAsClientClicked);
}

private void OnJoinAsHostClicked()
{
NetworkManager.Singleton.StartHost();
HideButtons();
}

private void OnJoinAsClientClicked()
{
NetworkManager.Singleton.StartClient();
HideButtons();
}

private void HideButtons()
{
_joinAsHostButton.gameObject.SetActive(false);
_joinAsClientButton.gameObject.SetActive(false);
}

This process makes it easy for users to participate as hosts or clients in shared AR sessions. Once all the necessary setup and preparation are complete, users can start the shared AR experience.

I wonder what action works when I build and run after completing the “Joining a Room using Shared Space Manager” step. I also wonder if I can check two players entering the room together.

This topic was automatically closed 2 hours after the last reply. New replies are no longer allowed.