Get SpatialOS

Sites

Menu

Connecting to a local deployment

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

Connecting your iOS device to a local deployment using Unity Remote

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

  1. Connect the mobile device to your computer using a USB cable.
  2. Open the project that you want to deploy with the Unity Editor and go to Edit > Project Settings > Editor to bring up the Editor Settings window.
  3. Open the scene that starts both your client- and server-workers.
  4. In the Unity Remote section, click on the drop-down menu beside the Device option and select Any iOS Device.
  5. On your mobile device, open the Unity Remote app. Make sure you allow it permissions for location and camera.
  6. In the 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

  7. In the Editor’s Game view, select Play.

    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.

  8. You should now see your Unity Editor game view mirrored on your iOS device.

Connecting your iOS simulator to a local deployment

  1. Build your server-workers.
  2. In a terminal window from the root folder of your SpatialOS project, run: spatial local launch mobile_launch.json.

    You cannot use SpatialOS > Local launch in your Unity Editor, because you need to specify a different launch configuration.

    It’s done when: You see the following message in the terminal: SpatialOS ready. Access the Inspector at http://localhost:21000/inspector

  3. In the Unity Editor, navigate to Edit > Project Settings > Player > Settings for iOS > Other Settings > Configuration > Target SDK and choose Simulator SDK.

  4. In the Unity Editor, navigate to File > Build Settings and click Build and Run. This prompts you to choose where to save the XCode project that Unity generates. After you’ve selected the directory, Unity generates the XCode project, opens it in XCode and starts the build. If the build succeeds, XCode starts a Simulator and installs the game on it.

    • If you choose Build, instead of Build and Run, Unity generates a XCode project and opens the folder containing the project.
  5. Once the game is deployed and started on the Simulator, you see an empty text field and a Connect button: Select Connect.

    You don’t need to enter anything in the text field.

  6. Play the game on the Simulator.

Connecting your iOS device to a local deployment

  1. Set up Code signing and provisioning.
  2. Make sure your computer and your mobile device are both connected to the same wireless network.
  3. Connect the mobile device to your computer using a USB cable.
  4. Build your server-workers.
  5. You need to know the local IP address of your computer to connect. This page (on the Lifehacker website) describes how you can find your external and local IP address.
  6. In a terminal window from the root folder of your SpatialOS project, run: spatial local launch mobile_launch.json --runtime_ip=<your-local-ip>. (Where <your-local-ip> is the IP address you just located.)

    You cannot use SpatialOS > Local launch in your Unity Editor, because you need to specify the runtime IP.

    It’s done when: You see the following message in the terminal: SpatialOS ready. Access the Inspector at http://localhost:21000/inspector

  7. In the Unity Editor, navigate to Edit > Project Settings > Player > Settings for iOS > Other Settings > Configuration > Target SDK and choose Device SDK.

  8. In the Unity Editor, navigate to File > Build Settings and click Build. This prompts you to choose where to save the XCode project that Unity generates. Select a directory and Unity generates the XCode project. After the build has finished, Unity opens the folder containing the project. Open the project in XCode, select the Project root, go to General > Signing and sign the project.

    If you choose Build and Run instead of Build Unity generates the XCode project, automatically opens it for you and starts the build to install the game on the connected device. This will most likely fail, because you need to first sign the application as described in the previous step.

    For subsequent runs you will be prompted to pick XCode project directory again (with the one used previously preselected). You can generate a new project or append/replace existing one. In subsequent runs, if you’ve set up provisioning and use Append, you can use Build and Run to trigger project run automatically after XCode project was generated.

  9. Once the game is running on your device, you see an empty text field and a Connect button: enter the local IP address of your computer in the text field and click Connect.

  10. Play the game on your mobile device.

Search results

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums