Get SpatialOS


You are viewing the docs for 11.0, an old version of SpatialOS. 12.0 is the newest →

Configuring a worker

This section explains where and how to configure the workers in a SpatialOS project.

Worker directory

Code for workers goes in directories in the workers/ directory of a project, for example workers/unity.

You’re not limited to one worker per directory: if workers share code or assets, they can go in the same directory. For example, the workers/unity/ directory should contain both the UnityWorker and the UnityClient.

Configuration file

Each worker needs a worker configuration file, with the name spatialos.<worker_type>.worker.json: for example, spatialos.UnityWorker.worker.json or spatialos.UnityClient.worker.json.

Once you’ve chosen a label for the worker type (eg myWorkerType), you MUST use this exact label consistently throughout your project to identify this worker type.

Note: Due to current UnitySDK limitations, the type of Unity-based workers MUST be either UnityWorker or UnityClient.

The files have the following structure:

    "build": { ... },
    "bridge": { ... },
    "managed": { ... },
    "external": { ... }
  • The build field (required) describes how to build the worker.
  • The bridge field (required) configures information like what components the worker is interested in.
  • The managed field (optional) tells SpatialOS how to run the worker as a managed worker in the cloud. Using this field makes a worker a managed worker.
  • The external field (optional) specifies how to launch the worker as an external worker locally, using spatial local worker launch. Using this field makes a worker an external worker.

Applying configuration changes

The bridge and managed worker configurations are built into the assembly at the start of building a worker.

To apply changes to these configurations to a local deployment, run:

  1. spatial worker build or spatial worker build <worker_type>.
  2. spatial local launch. (The changes won’t get reloaded into a running deployment.)

To apply changes to these configurations to a cloud deployment, run:

To have them applied when running a cloud deployment, you will need to run:

  1. spatial worker build or spatial worker build <worker_type>.
  2. spatial cloud upload.
  3. spatial cloud launch using the assembly you just uploaded.

Adding a new worker

To add a new worker to a project, create a worker configuration file in a new or existing worker directory.

If you’re using generated build scripts, to generate the build scripts, run spatial worker build <worker_type>

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums