Port your project to SpatialOS
3. Launch a local deployment
Now you can launch a local deployment of your game. To do this:
Step 1. Make your project use SpatialOS networking
In the Unreal Editor, from the toolbar, open the Play drop-down menu and check two checkboxes:
- Check the box for Run Dedicated Server
- Check the box for Spatial Networking
Image:The Unreal Engine Play drop-down menu, with Run Dedicated Server and Spatial Networking highlighted
Step 2. Launch a local deployment
Before you launch a local deployment, you must:
- generate schema (which creates entities)
- generate a snapshot
What is Schema?
Schema is a set of definitions which represent your game’s objects in SpatialOS as entities. Schema is defined in .schema files and written in schemalang. When you use the GDK, the schema files and their contents are generated automatically so you do not have to write or edit schema files manually.
You can find out more about schema, including how to generate it from the command line, making schema work with source control, and how to exclude certain directories from schema in the GDK schema documentation
What is an entity?
An entity is the SpatialOS equivalent of an Unreal Actor. It’s made up of a set of SpatialOS components. Each component stores data about the entity. (Note that SpatialOS components are not the same thing as Unreal Actor Components.)
What is a snapshot?
A snapshot is a representation of the state of a SpatialOS world at a given point in time. A snapshot stores the current state of each entity’s component data. You start each deployment with a snapshot; if it’s a re-deployment of an existing game, you can use the snapshot you originally started your deployment with, or use a snapshot that contains the exact state of a deployment before you stopped it.
You can find out more about snapshots in the GDK snapshot documentation.
To launch a local deployment:
- In the Editor, on the GDK Toolbar, open the Schema drop-down menu and select Schema (Full Scan).
Image: On the GDK toolbar in the Editor, select Schema (Full Scan)
- Select Snapshot to generate a snapshot.
Image: On the GDK toolbar in the Editor, select Snapshot
- Select Start. This opens a terminal window and starts a local SpatialOS deployment. Your game is ready to play when you see the output
SpatialOS readyin your terminal window.
Image: On the GDK toolbar in the Editor, select Start
- On the Editor toolbar, open the Play drop-down menu.
- Under Multiplayer Options, set the number of players to 2 and ensure that the checkbox next to Run Dedicated Server is checked. (If it is unchecked, select the checkbox to enable it.)
Image: The Unreal Engine Play drop-down menu, with Multiplayer Options and New Editor Window (PIE) highlighted
- Under Modes, select New Editor Window (PIE) to run the game. This starts one SpatialOS server-worker instance and two SpatialOS client-worker instances locally, in your Unreal Editor. The server-worker instance is acting as an Unreal server and the two client-worker instances are acting as two Unreal game clients (as would be used by two game players). You can switch between the two Editor windows to see and interact with each game client.
- If the game does not run automatically after selecting New Editor Window (PIE), on the Editor toolbar, select Play to run the game. Image: On the Unreal Engine toolbar, select Play
- When your game is running, select Inspector to open the Inspector in your default web browser. The Inspector is a web-based tool that you use to explore the internal state of a SpatialOS world. It gives you a real-time view of what’s happening in a local or cloud deployment. Image: On the Unreal Engine toolbar, select Inspector
- When you’re done, select Stop in the GDK toolbar to stop your local SpatialOS deployment.
Image: On the GDK toolbar in the Editor, select Stop
To run a local deployment with managed workers, or a cloud deployment, take a look at the Starter Template guide
You have now ported your Unreal game to GDK.
> Next: Logs and modifications
_2019-08-02 Page updated with editorial review: updated project.
2019-07-16 Page updated with editorial review.