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 managed workers.
This guide assumes you have a working SpatialOS project which you can already deploy locally.
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.
1. Find the IP of the host machine
One machine will host the deployment, meaning that it’s the machine where the SpatialOS runtime and local deployment runs.
First, find the IP address of the machine you want to use as the host machine.
Follow this guide to find your IP address on Mac.
2. Set up the other machines
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:
For workers built using the Worker SDK
To do this, make sure
UseExternalIp is set to true, and pass the host IP address
as the hostname into the connection method.
3. Launch a deployment
Using 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.
4. Connect workers to the host machine
Now the workers are configured to connect to the host machine, you can launch workers on other machines that can connect to the deployment. These can be clients, or workers that would usually be run as managed workers. You can run the workers as normal and they will connect to the host’s local deployment.
You can run the workers directly using
spatial local worker launch.