How to create a VR Multiplayer game with Unity using Sandboxing

While developing Vikubb, we have struggeled with severe Workflow issues as VR Unity Multiplayer development brings along some special requirement and restrictions we were not aware of from the beginning. After trying multiple approaches, I think I found a good workflow which does not only allow proper testing, but significantly will reduce development & iteration time.

First, let me point out the major issues:

  • If you want to test a 2 Player MP game it’s not possible to do that in your Unity Editor instance, but it is necessary to build your game as a second instance, as you cannot work in the same project with 2 Unity Editors. This is not a big deal at the beginning of development as the player is built quite quickly, however with 1 year into VK development, the build time is around 15-20 mins even though the game is quite small compared to other titles. Another major issue is that you might want do check the second instance in Edior mode or debug it which is not possible if built as player.
  • You can’t have 2 VR clients run at the same time. If you do, this will crash the build app or the Editor. In Editor, you can turn off in the VR Support in the Player Settings for one instance but 1) you will keep forgetting it, requiring to re-build over and over and 2) the setting is not reliable as it keeps jumping back from time to time.

A solution for both these issues would be to have 2 Unity Instances installed to 2 PC with seperate VR headsets. This however might not be possible for many developers. In this article, I will show you how you can achieve a proper setup using Sandboxing. This will mean some effort to setup, but will save you tons of time during your development process

So our goal is the following:

  1. Find a way to have 2 VR clients run at the same time on one PC without having to adjust settings all the time
  2. Find a way to not reqire building a player for every iteration

And here’s our solution to it: Sandboxing

Using Sandboxing, you can create a second PC instance on your computer. It’s fairly simple to do and gives you a lot of possibilities.

In our setup, we will setup Unity in a different Sandbox and use Git to transfer files between our instance and the sandbox. All required tools are available for freeRequirements:

  • You use version control (we use git, but you can use anything you want). If you don’t, you should!!
  • You have a non-VR mode implemented, allowing you to roughly start / control the game even though no headset is connected.
    My recommendation would be to always have this, as this will make testing, even in a single instance, much easier. If you haven’t done this already, have a look at the fantastic VRTK which offers this capability

HowTo:

Installation:

  • Download Sandboxie
  • Create a new Sandbox after installation
  • In your sandbox, install the following applications:
    • Unity (same version as your non-sandboxed version!)
    • Optional: Steam (create a new account as well)

Setup:

  • Run your Git Client (or whatever Version Control you use) in the Sandbox
    (e.g. Right-Click the Client executable -> Run Sandboxed)
  • Clone your project from the remote into a new repository
  • Start Unity In the sandbox
    (e.g. Right-Click the Client executable -> Run Sandboxed)
  • Open the project you cloned

And you’re done!

Workflow

  • To avoid conflicts, only do changes in the non-sandboxed version
  • Once the change is done, commit the change and push to remote
  • Pull the change in the Sandboxed git
  • Change is available in the Sandbox!