Integrating a game engine with SpatialOS
This section of the docs covers the basics of integrating a game engine with SpatialOS.
Improbable has built two game engine integrations, which are now open-source: the Unity and Unreal SDKs. 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 SDKs 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 SDKs. 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, those SDKs (in C#, C++ and Java) are deliberately low-level. They expose 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 open-source Unity SDK maps SpatialOS entities to Unity GameObjects), it can make it much easier when you’re writing a worker. That’s 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 SDKs 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).
- What the architecture of the open-source Unity integration looks like, to give you an example and a reference to an existing integration.
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 - the languages for which SpatialOS has SDKs.
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 C++, C# or Java SDK for the server-side.
It’s also worth noting that the SpatialOS SDKs are not thread safe. You’ll need to decide on a threading model as part of your integration.