Switching between Multiplayer and Single player

  • Issue category: Multiplayer / Networking
  • Device type & OS version: Android / iOS
  • Host machine & OS version: Mac
  • ARDK version:

Hi all,

I am trying to understand how to switch between a multiplayer and a single player mode at runtime. I currently have a single player mode that I want to turn into a shared session at runtime, and then back to single player potentially. I am using the ARSessionManager and ARNetworkingManager. My idea was to simply enable/disable the ARNetworkingManager and NetworkSessionManager to switch between the modes. But it seems they get enabled/disabled automatically somehow… perhaps by the Use with AR networking session flag?

Would this approach even work? If not, what is the proper way of doing this? Also, it seems that the flag Use with AR networking session is not editable at runtime?

Any pointers would be appreciated.

Hello Julian,

Rather than enabling/disabling entire components, you could enable/disable features using methods within these components. For instance, as shown in the ARNetworkingManager documentation, you can call DisableFeatures() in the ARNetworkingManager script to pause the AR session and leave the MultipeerNetworking session, which would allow you to return to a single player experience.

Also, the ‘Use with AR Networking Session’ flag should be true if your ARSessionManager is being used in conjunction with an ARNetworkingManager.

Please let me know if this helped solve your issue or if you have any further questions. Thank you!

Hi Stacy,

Thank you for the tips. So is this the correct approach to switch between Single player and Multiplayer modes?

Basic Setup

void Awake()  // somewhere in my game code
       networkManager.Initialize();  // this makes sure the manager is Initialized at the app start

This will ensure the ARSession is set up to work with networking and that the networking is Initialized, but not enabled yet so everything is running Single Player at the moment.

Switching to Multiplayer

ARNetworkingFactory.ARNetworkingInitialized += OnAnyARNetworkingSessionInitialized;

private void OnAnyARNetworkingSessionInitialized(AnyARNetworkingInitializedArgs {
    args.ARNetworking.PeerStateReceived += OnPeerStateReceived;
    args.ARNetworking.Networking.Connected += OnNetworkConnected;

Switching back to Single Player

networkManager.DisableFeatures();  // to disable the networking
sessionManager.EnableFeatures();   // to re-enable the ARSession which the previous line will disable

This seems to work in the Mock environment. Anything I am missing here?

Thanks for the help!

Hello Julian,

I’m glad to hear that it seems to work in the Mock environment!

It’s difficult to say with absolute certainty without seeing your entire project, but your proposed approach seems to be a correct way to switch from multiplayer to single player. If you end up running into any errors later on or have trouble when building to device, please reach out again so we can help troubleshoot. Thank you!

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