Get SpatialOS



Connect to a cloud deployment

Before reading this document, make sure you are familiar with:

To connect your mobile application to a cloud deployment, you need to authenticate against our services. This guide describes how to authenticate using the development authentication flow which we provide for the early stages of game development. Altenatively, if you want to create your own authentication server, follow this guide.

Connecting your Android device or emulator to a cloud deployment

  1. Start your Android Emulator in Android Studio or connect your Android device to your development computer.

    If you start an emulator, ensure you choose the same CPU architecture for your virtual machine as your development computer. Using a different architecture might affect the performance of your emulator.

  2. Build your server-worker types.

  3. Upload your server-worker types. To do this, open a terminal window and from the root directory of your SpatialOS project, enter spatial cloud upload <assembly name>.

  4. In the same directory, start your cloud deployment using spatial cloud launch --snapshot=snapshots/default.snapshot my_assembly <launch configuration>.json <deployment name>.

  5. In the SpatialOS Console, tag your cloud deployment with the tag dev_login.
    To do this:

    • From the SpatialOS Console, select your deployment name to display the project OVERVIEW screen.
    • In the OVERVIEW screen, there’s a Tag field, add dev_login to the field.
  6. Create a Development Authentication Token (SpatialOS documentation).

  7. Create a MonoBehaviour script which inherits from the MobileWorkerConnector and includes the functionality you want. In your Unity Editor, add this script it to your Android client-worker GameObject.

  8. The MobileWorkerConnector provides a DevelopmentAuthToken field. Still in your Unity Editor, make sure your Android client-worker GameObject is selected and in the Inspector, locate the script you just added to it.

  9. In the Inspector, in the script’s drop-down window, there is a field to add the authentication token that you created.

  10. In the same drop-down window, ensure that the checkbox ShouldConnectLocally is not checked.

  11. In the Unity Editor, navigate to SpatialOS > Build for cloud. Select your Android client-worker, and wait for the build to complete.
    You know it’s complete when it says Completed build for Cloud target in your Unity Editor’s Console window.

  12. Select SpatialOS > Launch mobile client > Android Device.

  13. Play the game on your Android device or emulator.

Search results

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums