Get SpatialOS

SpatialOS

Company

Careers

Sites

Technical Breakdown

Find out more about how SpatialOS works and how it can help you develop bigger, more complex games.

The Current Approach

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.

How SpatialOS is Different

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.

Abstraction

What makes up your world?

Entities

All things in your world exist as entities. SpatialOS maintains the persistent state of all entities across a cluster of servers. Worlds can contain millions of entities.

Components

Entities consist of components, which define their state and how other entities interact with them. Components are defined in a schema language. Automatically generated integrations then allow different workers to visualize and simulate them.

Workers

Workers are micro-services that simulate the components of entities across the world. SpatialOS runs as many workers across your world as needed to simulate every component in the world. All data synchronization is handled for you.

Code

How do you write it?

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 Nothing ignite(IgniteRequest);
    }
    
    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();
            }
        }
    }
              

Try it yourself

Set your own entities on fire across multiple workers in the SpatialOS Wizards demo. You’ll need to make an account first.

Tools

How do you manage your worlds?

Build your game with Unity, Unreal or a supported language SDK (C#, C++, Java), and deploy it with only a few CLI commands. Use our web-based console to keep track of all deployments: explore your world in the Inspector, diagnose and debug issues using logs, and view game metrics on a dashboard.

We've got you covered

Visit our documentation to learn more about the core concepts of SpatialOS. You’ll also find tutorials to help you get started, and information about using our SDKs.

Create worlds where everything matters

Contact us to discuss how we can work together to accomplish your vision, or jump straight in and try SpatialOS for free.