At Improbable, we get a lot of questions about SpatialOS, and in particular how it works with game engines. We thought it would be helpful for the developer community if we explained how SpatialOS works and how developers use game engines with it.
The most important points we will cover are:
- SpatialOS is a cloud platform for developing and hosting multiplayer games in the cloud. Its main features are server networking and game hosting.
- SpatialOS isn’t a game engine, nor does it contain any game logic. Developers upload whatever server-side game executables they want, and we run the executables inside containers for them. Game clients communicate with these executables through our server networking layer.
- We provide networking libraries in multiple languages (e.g. C, C#, C++, Java) for developers to use their own tools and game engines. We also provide open source toolkits to help developers use SpatialOS with popular game engines.
What is SpatialOS?
SpatialOS is a cloud platform for developing and hosting multiplayer games. It empowers developers to create innovative games which are able to use more than one game server in a single instance. This means that games powered by SpatialOS can vary from smaller-scale session-based titles to persistent worlds with very large scale, high player count and much complexity.
SpatialOS is made up of a number of different services that are designed to work together:
The SpatialOS Worker Service allows developers to upload server executables and host them on our cloud platform. We call these executables workers. Workers are often game engine dedicated servers, but can also be made from custom-built code written in C#, C, C++, or Java. This is not something we dictate - it’s up to the developer. Workers run in containers, in a similar fashion to other hosting services.
The SpatialOS Runtime is our unique networking solution. It allows game clients and game servers (running in the Worker Service) to communicate with each other. The Runtime also has an entity database which saves the state of your game world.
The SpatialOS SDK is a set of packages that developers can use to build games that use these cloud services. This is similar to how cloud providers like Amazon’s AWS, Google’s GCP or Microsoft’s Azure provide an SDK. It contains:
- Tools for developers to upload their game server executables for the Worker Service to host.
- Networking libraries to allow their game clients and servers to communicate through the Runtime using our networking protocol. We provide these for C, C++, C# and Java.
- Tools for understanding, monitoring and debugging game instances.
- Tools for running game sessions locally for testing.
How is the SpatialOS Worker Service different from other game hosting solutions?
The Worker Service is similar to other game server hosting options (e.g Kubernetes or GameLift). Our platform manages the lifecycle of workers, scaling the number of them according to a load balancing policy decided by the developer. It also manages worker failures and can restart them when they crash.
How does the SpatialOS Runtime differ from other game networking solutions?
- Multiserver: Multiple game servers can connect to a single game instance. This allows the world to be larger and have more complexity than a single game server can handle.
- Persistence: the synchronised data of the game is routed through, and stored in, memory. This allows the game to be resumed from a previous point in time and recover from crashes.
- Distributed networking: the Runtime runs across multiple servers, allowing it to handle more concurrent players, NPCs and objects in a game instance than a single server could.
- Rich interest management: game servers and clients only see objects in the game world they need to see.
- Client agnostic: the Runtime also allows for clients and servers of different types to communicate together using our data definition language.
Is SpatialOS a game engine, or built using game engines?
It is neither. SpatialOS is a set of cloud services for hosting and networking game engines, but it is not built using them. The only game engines present are those a developer uploads and runs on our platform as part of their game.
In what ways do developers use game engines with SpatialOS?
Games almost always use a game engine as a game client. They usually also use a game engine for server-side logic (running in our Worker Service).
Does SpatialOS require workers to be game engines?
No. Running game engines server-side can be useful to prevent cheating, or when you want to run the same code on clients and servers for predictive purposes. However, many games only need simpler workers (not full game engines) to run, which can be built without an engine; some developers have even used scripting languages like Lua on top of our C SDK.
How do games use Unity with SpatialOS?
- The SpatialOS Game Development Kit (GDK) for Unity. This is an open source toolkit we maintain to make it much easier to use Unity as a game client connected to SpatialOS hosted games, or with the option of a game server running in our Worker Service. We in no way modify the Unity game engine. Developers upload their Unity binary and we run it for them inside containers. We also provide example solutions to common multiplayer problems such as physics synchronization, player movement and shooting.
- The SpatialOS SDK in C#. Some studios want more flexibility and choose to build their own APIs. The SpatialOS base SDK is suitable for this.
How do games use Unreal with SpatialOS?
- The SpatialOS SDK in C++ or C. Developers can use Unreal Engine without modifying its source code, using our networking APIs directly instead of those provided by Unreal.
- The SpatialOS Game Development Kit (GDK) for Unreal. We are collaborating with Epic on a fork of Unreal Engine. This project re-implements Unreal’s networking to communicate through our networking layer, making it much easier for Unreal games to run on our platform and leverage our unique features.
How do games use CRYENGINE, or another engine, with SpatialOS?
It’s possible to use almost any commercial or open source game engine with SpatialOS. For example, Improbable and CRYENGINE are working to deliver official support for CRYENGINE and SpatialOS. However, the game studio Automaton Games has already built SpatialOS support for CRYENGINE. To do this, they used the C++ SDK. You can take a look at their code on Github.
Any further questions?
We hope these points were useful in explaining more about how SpatialOS works with game engines.
If you are interested in integrating another game engine, you can take a look at the source code of one of our GDKs or check out our docs. You’re also free to talk to us on our Discord or our forums.