Pirates x — Play in the cloud
In this lesson you’ll:
- initialize the project for cloud deployment
- create the assets needed to run a SpatialOS game
- upload these assets to the cloud
- run the command to run the game in the cloud
- share the deployment and play the game in multiplayer
Background: cloud deployment
Through the Pirates tutorial we show you how to run your game locally. But there are a few disadvantages to only deploying locally.
You can also deploy your game to the cloud. The advantages of doing this:
- You can test your game at a much larger scale.
- It’s easy to test multiplayer functionality.
- Anyone you share the game with can connect to it and play.
In a nutshell
For a quick visual guide of how to deploy a SpatialOS project to the cloud, see this cheat sheet:
1. Initialize the project
The first time you run a game in the cloud, you need to add some information to your project configuration:
- Open the project configuration file:
spatialos.json, in the project root directory.
your_project_name_here) to your SpatialOS project name.
You can find yours in the SpatialOS console. It’ll be something like
2. Build an assembly for the deployment
The first step of running a cloud deployment is uploading all the files that your game uses. This includes executable files for the clients and workers, and the assets your workers use (like models and textures used by the Unity client to visualize the game). We call that set of game files an assembly.
To build the assembly your game will use when running in the cloud:
- In the Unity Editor, in the SpatialOS window, select
Deploymentin the drop-down menu.
- Make sure both worker types (
UnityClient) are selected.
Alternatively, to build outside Unity, use the command
spatial worker build --target=deployment:
Close the Unity Editor.
If you don’t close Unity before running
spatial worker build, the command will report an error.
In the root directory of the project, run
spatial worker build UnityWorker UnityClient --target=deployment.
It’s done when: you see
'spatial.exe build' succeeded(or
'spatial build' succeededon Mac) printed in your console output.
3. Upload assembly to the cloud
spatial cloud upload <assembly name> uploads the assembly to the cloud. The
<assembly name> is just a label
so you can identify this assembly in the next step — for example,
To upload from Unity:
- In the SpatialOS window, under
Spatial upload, enter a name for your assembly — for example,
spatial cloud upload MyPiratesAssembly.
It’s done when: you see
'spatial.exe upload MyPiratesAssembly' succeeded (<time to finish>)printed in your console output.
4. Launch a cloud deployment
spatial cloud launch deploys a project to the cloud. Its full syntax is:
spatial cloud launch <assembly name> <launch configuration> <deployment name> --snapshot=<snapshot file>
<assembly name>is the name of the assembly the deployment will use. You just created an assembly with the name
<launch configuration>is the configuration file for the deployment. This project includes one called
<deployment name>is a name of your choice, which you’ll use to identify the deployment. Must be in lowercase.
<snapshot file>is the snapshot of the world you want to start from. This project includes one called
snapshots/default.snapshot. You’ll learn more about snapshots in the next lessons.
This command defaults to deploying to clusters located in the US. So if you’re in Europe, add the
for better performance.
If you’re in the US, deploy your game by running:
spatial cloud launch MyPiratesAssembly default_launch.json piratestutorial --snapshot=snapshots/default.snapshot
Or, if you’re in Europe:
spatial cloud launch MyPiratesAssembly default_launch.json piratestutorial --snapshot=snapshots/default.snapshot --cluster_region=eu
You’ll know it has worked when: you see
Successfully created deployment printed in your console output.
5. Play Pirates - in multiplayer!
You’ll see your project and the deployment you just created.
Click on the deployment’s name (
piratestutorial). This opens an overview of your deployment, which looks something like this:
To get links to share the game with others, click Share (on the top left).
This gives you a link that you can share.
Send the link to friends and colleagues, so they can launch the game on their own computers.
Launch the game on your machine by clicking ▷ Launch.
This prompts you to install the Improbable Launcher:
Install the Launcher.
Click Launch your Deployment, and play your game!
As your friends and colleagues join, you’ll see new pirate ships appear in your client:
6. Stop the deployment
Once you’ve finished playing, click STOP.
You should always stop a deployment once you’ve finished using or testing it.
Note: If you don’t stop a deployment, it will be stopped automatically 6 hours after it was started.
In this lesson you:
- ran the Pirates game in the cloud in three steps:
- build the project
- upload the assembly
- played the game using a client running using the Launcher
Was this page helpful?
Thanks for letting us know!
Thanks for your feedback
Need more help? Ask on the forums