Integrating a game engine with SpatialOS
This section of the docs covers the basics of integrating a game engine with SpatialOS.
Improbable has built game engine integrations, with source code available on GitHub, for Unreal and Unity. But if there’s a different game engine you want to use in your SpatialOS project, you may be able to integrate it yourself.
What is a game engine integration?
At the end of the day, a worker is just a program: one that uses the SpatialOS Worker SDK to interact with a SpatialOS world. You can use many things as part of that program - including a game engine. But if you want to build a worker that uses a game engine, you may want to do more than just straightforwardly use the base SpatialOS SDK. You might want to build a integration: the workflow and tooling required to run instances of that game engine as workers connected to a SpatialOS game.
For one thing, the Worker SDK (in C#, C++ and Java) is deliberately low-level. It exposes the underlying interactions with SpatialOS in quite a minimal way. Also, your game engine may have specific, native concepts that you want to make use of. If you can map SpatialOS concepts to the concepts in your game engine (for example, the way the GDK for Unity maps SpatialOS entities to Unity GameObjects), it can make it much easier when you’re writing a worker. That’s why a deep integration is useful: to make SpatialOS development feel more native to those engines.
A very basic game engine integration would just connect the game engine to SpatialOS, and get it building as a worker. A more sophisticated integration might build on top of the SpatialOS Worker SDK to make development in the engine easier, finding ways to interact with a SpatialOS world that feel idiomatic for developers used to working with the engine.
How do I integrate a game engine?
Each game engine is different, sometimes with unique internal concepts. How difficult an integration will be depends on how naturally the engine’s concepts map to SpatialOS concepts. But what we can tell you is:
- The requirements your engine must meet to make it possible to integrate with SpatialOS.
- The steps you’ll need to complete in order to integrate the engine (though we can only tell you what those steps are, not how to do them).
Integrating a game engine can be a big task, so if you have any questions that aren’t answered by this documentation, please get in touch on the forums.
Requirements for engine integration
In order to integrate with SpatialOS, a game engine must meet these requirements:
It needs to be written in or support C#, C++, or Java if using a Worker SDK with generated code. Otherwise, it only needs to be able to interact with a C API using the Worker SDK for C.
In order to run as a managed worker, it needs to be able to run:
- in Linux
- in headless (no graphics context) mode
- with root/administrator privileges
If it doesn’t meet these requirements, you’ll only be able to use it as an external worker, and you will have to use the Worker SDK in C, C++, C# or Java for the server-side.
It’s also worth noting that the Worker SDK is not thread safe. You’ll need to decide on a threading model as part of your integration.