Get SpatialOS

Sites

Menu

Connect to a local deployment

This page explains how to connect an Android client to a local deployment of SpatialOS. You can do this from inside your Unity Editor, using the Unity Remote app, using an Android Emulator or using your own Android device.

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

Prepare your project to connect to a local deployment

To connect your Android device to a local deployment, you need to prepare its configuration. Follow the steps below to ensure any local deployment you launch via your Unity Editor is correctly set up.

  1. Open your project in your Unity Editor.
  2. Navigate to SpatialOS > GDK Tools configuration to open the configuration window.
  3. In the Runtime IP for local deployment field, enter your local machine’s IP address. (You can find how to do this on the Lifehacker website.)
  4. Select Save and close the window.

Note: If you are using one of our Starter Projects, you can skip the Create a mobile connector script section below, as you already have one in your project.

Unity Editor

  1. In your Unity Editor, Select SpatialOS > Local launch.
    It’s done when you see the following message in the terminal: SpatialOS ready. Access the Inspector at http://localhost:21000/inspector.
  2. In your Unity Editor, open the FPS-Development Scene and select the Play button.

Unity Remote

You need your Unity Remote app for this. See the Unity documentation for details.

  1. Enable USB debugging on your mobile device. See the Android developer documentation for guidance.
  2. Connect the mobile device to your computer using a USB cable. You might get a pop-up window on the device asking you to allow USB debugging. Select Yes.
  3. In your Unity Editor, open the project that you want to deploy and go to Edit > Project Settings > Editor to bring up the Editor Settings window.
  4. In the Editor Settings window’s Unity Remote section, set the Device setting to Any Android Device.
  5. Open the Scene that starts both your client-workers and server-workers.
  6. On your mobile device, open the Unity Remote app. Make sure you allow it permissions for location and camera.
  7. In your Unity Editor, select SpatialOS > Local launch to start your local deployment.
    It’s done when you see the following message in the terminal: SpatialOS ready. Access the Inspector at http://localhost:21000/inspector.
  8. In your Unity Editor’s Game view, select Play.

    TIP: You can change the resolution of the Game view in your Unity Editor to make sure it does not appear stretched on your mobile device. Choose the resolution that’s identical to your mobile device to produce the best results.

  9. You should now see your Unity Editor’s game view mirrored on your Android device.

Android Emulator

  1. Start your Android Emulator in Android Studio.

    Ensure you choose the same CPU architecture for your virtual machine as your development computer. If you don’t, you will get warning messages as mismatched CPU architecture affects performance.

  2. Set up your local deployment.

  3. Build your server-workers.

  4. In your Unity Editor, select SpatialOS > Local launch to start your local deployment.
    It’s done when you see the following message in the terminal: SpatialOS ready. Access the Inspector at http://localhost:21000/inspector.

  5. Still in your Unity Editor, navigate to SpatialOS > Build for local. Select your Android worker, and wait for the build to complete.

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

  7. Play the game on the Emulator.

Android device

  1. Enable USB debugging on your mobile device. See the Android developer documentation for guidance.
  2. Make sure your computer and your mobile device are both connected to the same network.
  3. Connect the mobile device to your computer using a USB cable. You might get a pop-up window on the device asking you to allow USB debugging. Select Yes.
  4. In your Unity Editor, select SpatialOS > Local launch to start your local deployment.
    It’s done when you see the following message in the terminal: SpatialOS ready. Access the Inspector at http://localhost:21000/inspector.
  5. Still in your Unity Editor, navigate to SpatialOS > Build for local. Select your Android worker, and wait for the build to complete.
  6. Select SpatialOS > Launch mobile client > Android Device to start your Android client.
  7. Play the game on your device.

Search results

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums