Get SpatialOS

Sites

Menu

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 early stages in development. Alternatively, if you want to create your own authentication server, follow this guide.

Connecting your iOS device or simulator to a cloud deployment

  1. Build your server-worker types.
  2. 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>.
  3. In the same directory, start your cloud deployment using spatial cloud launch --snapshot=snapshots/default.snapshot my_assembly <launch configuration>.json <deployment name>.
  4. 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.
  5. Create a Development Authentication Token (SpatialOS documentation).
  6. 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.
  7. 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.
  8. In the Inspector, in the script’s drop-down window, there is a field to add the authentication token that you created.
  9. In the same drop-down window, ensure that the checkbox ShouldConnectLocally is not checked.
  10. 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.
  11. Select SpatialOS > Launch mobile client > Android Device.
  12. Go to your file manager and open the generated XCode project in the workers/unity/build/iOSClient@iOS directory.
  13. Code sign the project and build it - see the Building an XCode project using Unity section in the Unity documentation.
  14. Play the game on your iOS device or simulator.

Search results

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums