3: Test changes in the cloud
Step 1: Build your workers
When you build your workers, you create an assembly. They’re
.zip files that contain all the files that the SpatialOS Runtime uses when your run your game in the cloud.
To do this you run a batch file,
BuildWorker.bat. You can add different flags to the script but, for now, run the script twice, once with a flag for server-workers and once with a flag for cloud-workers:
What flags are there?
During development, you might want to, for example: * cook a headless standalone version of the game ready for upload to the SpatialOS cloud as a simulated player cloud deployment, or * cook a stand-alone version of the game to test it as a game client. The optional flags give you this functionality and more. See the Helper script documentation for details of all the options and how to use them.
To build workers:
- Close your Unreal Editor - if the Editor is open when you try to build workers, the command fails.
- Check the project’s networking is set to Spatial networking.
GDK projects default to using Spatial networking. However, if you have reset the networking switch to native Unreal networking, you need to set it back.
- In a terminal window, navigate to the
DefaultGame.iniconfiguration file (located in
- Check if the
bSpatialNetworkingoption is present. If it is, set it to
bSpatialNetworking=True), save the file and exit.
- In a terminal window, navigate to the
- Still in a terminal window, navigate to the
BuildProject.batcommand to build a server-worker using the filepath and flags below. The filepath you use depends on whether you used auto-install or manual-install when you cloned and set up the GDK’s fork and plugin.
Game\Plugins\UnrealGDK\SpatialGDK\Build\Scripts\BuildWorker.bat GDKShooterServer Linux Development GDKShooter.uproject
Plugins\UnrealGDK\SpatialGDK\Build\Scripts\BuildWorker.bat GDKShooterServer Linux Development GDKShooter.uproject
Now run the
BuildProject.batcommand to build a client-worker:
Game\Plugins\UnrealGDK\SpatialGDK\Build\Scripts\BuildWorker.bat GDKShooter Win64 Development GDKShooter.uproject
Plugins\UnrealGDK\SpatialGDK\Build\Scripts\BuildWorker.bat GDKShooter Win64 Development GDKShooter.uproject
Step 2: Upload your game
- In File Explorer, navigate to
spatialos.jsonin a text editor.
- Change the
namefield to the name of your project. You can find this in the Console. It’ll be something like
In a terminal window, change directory to
spatial cloud upload <assembly_name>, where
<assembly_name>is a name of your choice (for example
myassembly). A valid upload command looks like this:
spatial cloud upload myassembly
Note: Depending on your network speed it may take a little while (1-10 minutes) to upload your assembly.
Step 3: Launch a cloud deployment
The next step is to launch a cloud deployment using the assembly that you just uploaded. This can only be done through the SpatialOS command-line interface (also known as the SpatialOS CLI.
When launching a cloud deployment you must provide three parameters:
- the assembly name, which identifies the worker assemblies to use.
- a launch configuration, which declares the world and load balancing configuration.
- a name for your deployment, which is used to label the deployment in the Console.
In a terminal window, in the same directory you used to upload your game, run:
spatial cloud launch --snapshot=snapshots/default.snapshot <assembly_name> two_worker_test.json <deployment_name>
assembly_nameis the name you gave the assembly in the previous step and
deployment_nameis a name of your choice. A valid launch command would look like this:
spatial cloud launch --snapshot=snapshots/default.snapshot myassembly two_worker_test.json mydeployment
Note: This command defaults to deploying to clusters located in the US. If you’re in Europe, add the
--cluster_region=euflag for lower latency.
Step 4: Play your game
When your deployment has launched, SpatialOS automatically opens the Console in your browser.
- In the Console, Select the Launch button on the left of the page, and then click the Launch button that appears in the centre of the page. The SpatialOS Launcher, which was installed along with SpatialOS, downloads the game client for this deployment and runs it on your local machine.
- Once the client has launched, enter the game and fire a few celebratory shots - you are now playing in your first SpatialOS cloud deployment!
TIP: Check out the cloud deployment workflow page for a reference diagram of this workflow.
Step 5: Invite your friends
- To invite other players to this game, head back to the Deployment Overview page in your Console, and select the Share button.
- Share the generated link with your friends!
When you’re done shooting your friends, you can click the Stop button in the Console to stop your deployment.
- If you want to create a new game using the GDK, you should get the Starter Template.
- If you want to port your existing game to the GDK, follow the Porting guide.
2019-08-14 Page updated with editorial review: added filepaths based on auto-install or manual-install. 2019-08-02 Page updated with limited editorial review: updated project name. 2019-03-20 Page updated with limited editorial review.