Shared AR Session tutorial error

Include the following details (edit as applicable):

  • Issue category: Shared AR Session
  • Device type & OS version: n/a
  • Host machine & OS version: Windows 11
  • Issue Environment : Unity
  • Xcode version: n/a
  • ARDK version: latest
  • Unity version: 2021.3.8f1

Description of the issue:

In tutorial

At 5:58 approximately, this line does not work:

manager.NetworkSessionManager.Networking.Connected += OnNetworkInitialized;

I am assuming it is a namespace issue, I have the following:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

using Niantic.ARDK.Extensions;
using Niantic.ARDK.Networking.MultipeerNetworkingEventArgs;
using System.Linq;

public class ARGameLogic : MonoBehaviour
{
    public ARNetworkingManager manager;


    // Start is called before the first frame update
    void Start()
    {
        manager.NetworkSessionManager.Networking.Connected += OnNetworkInitialized;
    }

    void OnNetworkInitialized(ConnectedArgs) 
    { 
        
    }
    // Update is called once per frame
    void Update()
    {
        
    }
}

Thanks for the help!

Hello Luke,

Would you be able to provide a screenshot or copy paste the error message? I was able to run through the example without an issue.

The one problem I do see in the code that you provided is that the OnNetworkInitialized function does not have a variable named for its ConnectedArgs field.

Yours just says (ConnectedArgs), but it should say (ConnectedArgs args)

Yep fixed that, still the same issue.

Hi Luke,

I ran the tutorial again a second time up until the time stamp you provided and I also ran through the text version of the tutorial below the video and I am not running into any sort of issues when getting to that line. I don’t see any errors in the Unity Editor nor do I see any errors in my text editor (VS Code)

I would like to ask some clarifying questions:

  1. Is there a visible red squiggly line below that line of code indicating an error? If so, can you please provide a screenshot or copy paste the error in your next reply?
  2. If there is no red squiggly line to indicate an error, where are you seeing this error/ how are you finding out about it? Is it through the Debug Console? If so, can you please copy and paste the error here or send a screenshot?

Can you try the following:

  1. Check the Inspector of the ARGame GameObject that you created in the tutorial to make sure that you added the ARNetworkingSceneManager into the public Manager field. If all that is accounted for, try step 2.
  2. Add a second semicolon at the end of any line of code (essentially a blank statement) to force the editor to recompile the script and check if the error goes away. You can also try closing and reopening Unity or switching scenes and switching back (I have seen this remove errors that sometimes linger in the Console)
  3. Close your Unity project, navigate to the folder where it’s located in your computer and delete the Library folder. Start your project back up and let it rebuild the Library folder and then check to see if that line is now recognized.
  4. If the above didn’t work, delete ARDK, redownload it and re-import it

The issue appears to be an issue with VS and Unity communicating. I switched to VS Code, and that seems to solve the errors.

Thank you for the help.