Get SpatialOS

Sites

Menu

Running a local deployment across multiple machines

You can connect multiple machines together to collectively run a SpatialOS world. One machine will host the SpatialOS world, and you can launch workers on other machines that connect to that deployment.

This can be especially useful when developing mobile or VR games, as you can run the SpatialOS deployment on your computer and connect the mobile or VR client. You can also use it to debug multiple managed workers.

This guide assumes you have a working SpatialOS project which you can already deploy locally.

When you release a game commercially, you must use a cloud deployment: our EULA doesn’t allow you to release a game by running a local deployment across multiple machines.

Requirements

All of the machines which you want to run the deployment on must be on the same local network: specifically they must be able to ping each other’s IP addresses.

Set up the host machine

One machine will host the deployment, meaning that it’s the machine where the SpatialOS runtime and local deployment runs.

  1. First, you need to find the IP address of the machine you want to use as the host machine.

    Follow this guide to find your IP address on Windows 10, and this guide for versions of Windows below that.

    Follow this guide to find your IP address on Mac.

  2. Once you have the host machine’s IP address, run the following command on the host machine inside the project root directory:

    spatial local launch default_launch.json --runtime_ip=<host IP address>
    

    This starts the local deployment on the host machine.

Set up the other machines

You can now launch workers on other machines that can connect to the deployment. These can be client workers, or workers that would usually be run as managed workers (for example, UnityWorkers or UnrealWorkers).

Setting the IP address

You need to configure each of your workers to connect to the host machine instead of trying to connect to a local deployment on the same machine. To do this:

You will need to undo these steps if you want to go back to the default behaviour, which connects to a local deployment on the same machine.

For workers built using the Unity SDK

  1. Open the scene for the worker type which you want to connect (UnityClient or UnityWorker).

  2. Find the Bootstrap component on the GameEntry game object. In Configuration -> Networking, change the Receptionist Host to the IP address of the host machine which you found earlier.

    Unity set IP address

Alternatively, in the worker configuration file, add the following to the command line arguments in the external block:

"arguments": [
    ...
    "+receptionistHost",
    "<host_ip_address>"
]

This will override the IP address in the Bootstrap component when you launch using spatial local worker launch.

For workers built using the Unreal SDK

  1. Find your default Game Mode blueprint and open it.

  2. Change the Worker Id Override field in this blueprint to the host machine’s IP address. Make sure Use External Ip is set to true.

    Unreal set IP address

Alternatively, in the worker configuration file, add the following to the command line arguments in the external block:

"arguments": [
    ...
    "+receptionistHost",
    "<host_ip_address>"
]

This will override the IP address in the Game Mode blueprint when you launch using spatial local worker launch.

For workers built using the language-specific SDKs

The Connection object (C++, C# and Java) describes how the worker should connect to SpatialOS. You need to modify this to connect to the host’s IP address.

To do this, make sure UseExternalIp is set to true, and pass the host IP address as the hostname into the connection method.

Connecting to the host machine

Once the workers are configured to connect to the host machine, you can run the workers as normal and they will connect to the host’s local deployment. For example, you can run the workers directly from the Unity or Unreal editors, or use spatial local worker launch.

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums