Engine Integration
Build your game logic with Unity, Unreal or a supported language SDK (C#, C++, Java).
Improbable’s SpatialOS platform gives you the power to seamlessly stitch together multiple servers and game engines like Unreal and Unity to power massive, persistent worlds with more players than ever before.
SpatialOS can create a swarm of hundreds of conventional game engines that overlap together to create a huge, seamless world. Develop unconstrained by the computational and concurrent player limits of a single engine.
A SpatialOS world can contain millions of persistent entities and manage their state and history. Design gameplay that allows players to affect the world in meaningful, long-lasting ways.
Use just a few CLI commands to run your world on the SpatialOS Platform, then instantly share with players. SpatialOS handles all infrastructure management and data synchronization for you, greatly increasing the speed at which you can build and grow your online world.
Online worlds or shards are often constrained to the single server running them.
This limits you in terms of world scale, reliability, and concurrent players. The hassle of managing servers yourself results in a much slower development and iteration process.
SpatialOS is a cloud-based computational platform that lets you use many servers and engines to power a single world.
The platform coordinates a swarm of micro-services called workers, which overlap and dynamically reorganize to power a huge, seamless world.
The platform also lets you handle a huge number of concurrent players across different devices in one world.
Implement flammability with SpatialOS and Unity3D
A code example from the SpatialOS demo introduces a basic concept of flammability to entities in your game world. SpatialOS executes this code across many workers simultaneously, allowing flammability behaviour to run across a huge number of entities and be visualized by many connected clients simultaneously.
// The SpatialOS Schema Language lets you define cross-language
// components, that can be implemented and visualized across a
// variety of languages and integrations
component Flammability {
id = 1000;
// This property defines the persistent state of this entity potentially being on fire
bool is_on_fire = 1;
// Commands provide a way of workers interacting with other workers.
// These workers could be even written in different langauges!
command IgniteRequest ignite returns Nothing;
}
type IgniteRequest {
// could contain additional parameters
}
Expand
// Would be added to GameObjects that exist on Unity server worker.
// Potentially hundreds of server workers could be running in the same world.
class PropagateFlamesBehaviour : MonoBehaviour {
// FlammabilityWriter is code generated for you
// using our SpatialOS Schema compiler, and injected
[Require] private Flammability.Writer flammabilityWriter;
void OnEnable() {
// Set up a handler for when we get an Ignite command
flammabilityWriter.CommandReceiver.OnIgnite.RegisterResponse(HandleIgnite);
}
// When the trigger around the flaming GameObject intersects another entity
void OnTriggerEnter(Collider other) {
if (flammabilityWriter.Data.isOnFire) {
// SpatialOS RPCs will route to whichever worker is simulating this Component.
SpatialOS.Commands.SendCommand(flammabilityWriter,
Flammability.Commands.Ignite.Descriptor,
new IgniteRequest(),
other.gameObject.EntityId());
}
}
private Nothing HandleIgnite(Nothing request, ICommandCallerInfo callerinfo) {
if (!flammabilityWriter.Data.isOnFire) {
flammabilityWriter.Send(new Flammable.Update().SetIsOnFire(true));
}
return new Nothing();
}
void OnDisable() {
flammabilityWriter.CommandReceiver.OnIgnite.DeregisterResponse();
}
}
Expand
// Would be added to GameObjects that exist on Unity client worker.
// Arbitrarily many Unity clients would be running this code
class FlamesVisualizer : MonoBehaviour {
// FlammabilityReader is code generated for you
// using our SpatialOS Schema compiler, and injected
[Require] private Flammability.Reader flammabilityReader;
// This will reference a ParticleSystem on the GameObject
public ParticleSystem particles;
void OnEnable() {
// Re-visualize when we're set on fire
flammabilityReader.IsOnFireUpdated.Add(UpdateVisualization);
UpdateVisualization(flammabilityReader.Data.isOnFire);
}
void UpdateVisualization(bool isOnFire) {
// Enable the ParticleSystem as appropriate
if (isOnFire) {
particles.Start();
} else {
particles.Stop();
}
}
}
Expand
// The SpatialOS Schema Language lets you define cross-language
// components, that can be implemented and visualized across a
// variety of languages and integrations
component Flammability {
id = 1000;
// This property defines the persistent state of this entity potentially being on fire
bool is_on_fire = 1;
// Commands provide a way of workers interacting with other workers.
// These workers could be even written in different langauges!
command IgniteRequest ignite returns Nothing;
}
type IgniteRequest {
// could contain additional parameters
}
// Would be added to GameObjects that exist on Unity server worker.
// Potentially hundreds of server workers could be running in the same world.
class PropagateFlamesBehaviour : MonoBehaviour {
// FlammabilityWriter is code generated for you
// using our SpatialOS Schema compiler, and injected
[Require] private Flammability.Writer flammabilityWriter;
void OnEnable() {
// Set up a handler for when we get an Ignite command
flammabilityWriter.CommandReceiver.OnIgnite.RegisterResponse(HandleIgnite);
}
// When the trigger around the flaming GameObject intersects another entity
void OnTriggerEnter(Collider other) {
if (flammabilityWriter.Data.isOnFire) {
// SpatialOS RPCs will route to whichever worker is simulating this Component.
SpatialOS.Commands.SendCommand(flammabilityWriter,
Flammability.Commands.Ignite.Descriptor,
new IgniteRequest(),
other.gameObject.EntityId());
}
}
private Nothing HandleIgnite(Nothing request, ICommandCallerInfo callerinfo) {
if (!flammabilityWriter.Data.isOnFire) {
flammabilityWriter.Send(new Flammable.Update().SetIsOnFire(true));
}
return new Nothing();
}
void OnDisable() {
flammabilityWriter.CommandReceiver.OnIgnite.DeregisterResponse();
}
}
// Would be added to GameObjects that exist on Unity client worker.
// Arbitrarily many Unity clients would be running this code
class FlamesVisualizer : MonoBehaviour {
// FlammabilityReader is code generated for you
// using our SpatialOS Schema compiler, and injected
[Require] private Flammability.Reader flammabilityReader;
// This will reference a ParticleSystem on the GameObject
public ParticleSystem particles;
void OnEnable() {
// Re-visualize when we're set on fire
flammabilityReader.IsOnFireUpdated.Add(UpdateVisualization);
UpdateVisualization(flammabilityReader.Data.isOnFire);
}
void UpdateVisualization(bool isOnFire) {
// Enable the ParticleSystem as appropriate
if (isOnFire) {
particles.Start();
} else {
particles.Stop();
}
}
}
SpatialOS is designed to unlock developers’ creativity, from the smallest indie team to industry titans. Read testimonials from SpatialOS developers about building games on this radical new tech!
And be sure to check our blog and forums for new technical approaches and game-play ideas.
Help each other out, play each other’s games. We’re in it together!