Get SpatialOS

Sites

Menu

Connect to a local deployment

This page describes how to connect an iOS client to a local deployment of SpatialOS. You can do this using either; just yourUnity Editor, the Unity Remote app, the iOS Simulator, or your own iOS device.

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

Prepare your project to connect to a local deployment

To connect your iOS 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 the Unity Remote app installed on your iOS device in order to follow steps below. See the Unity documentation for details.

  1. Open your project in your Unity Editor.
  2. Build your workers from the SpatialOS menu by selecting Build for local > All workers.
  3. Connect your iOS device to your computer using a USB cable. Accept the Trust This Computer alert if it appears.
  4. Open the project that you want to deploy with your Unity Editor and go to Edit > Project Settings > Editor to bring up the Editor Settings window.
  5. In the Unity Remote section, select Device > Any iOS Device.
  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.
    It’s done when you see the following message in the terminal: SpatialOS ready. Access the Inspector at http://localhost:21000/inspector.
  8. Open the Scene that starts both your client-workers and server-workers. In the FPS Starter Project this is FPS-Development.scene.
  9. In the 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.

  10. You should now see your Unity Editor Game view mirrored on your iOS device.

  11. When you’re done:

    • Select Play to stop your client.
    • In the terminal window that’s running the SpatialOS process, enter Ctrl+C to stop the process.

iOS Simulator

Note: You cannot run the First Person Shooter (FPS) Starter Project on the iOS Simulator. This is due to an incompatibility between the Metal Graphics API used by the project and the iOS simulator.

  1. Open your project in your Unity Editor.
  2. In your Unity Editor, select File > Build Settings, and ensure that iOS is selected. (The Unity logo next to a platform name indicates it’s selected.)
    If iOS is not selected, select it and then select Switch Platform.
  3. In your Unity Editor, select Edit > Project Settings > Player. This opens the Project Settings window.
  4. In the Inspector window, select Settings for iOS (the iPhone icon) > Other Settings.
  5. In the Configuration section of the Inspector window, locate Target SDK and select Simulator SDK.
  6. Still in the Configuration section, locate Target minimum iOS version and input 10.0.
  7. Build your workers from the SpatialOS menu by selecting Build for local > All workers.
  8. 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.
  9. In your file manager, navigate to /workers/unity/build/worker/ and locate the .xcodeproj that corresponds to your iOS client-worker, it may be in a sub-folder.
    Open it in Xcode.
  10. Still in XCode, select the Play button in the top left of the window.
  11. Once the game is deployed and started on the Simulator, you see an empty text field and a Connect button: Select Connect.
    Note: You don’t need to enter anything in the text field.
  12. Play the game on the Simulator.
  13. When you’re done:
    • Exit the Simulator
    • In XCode, select the Play button to stop your the game running.
    • In the terminal window that’s running the SpatialOS process, enter Ctrl+C to stop the process.

iOS device

  1. Make sure your computer and your mobile device are both connected to the same network.
  2. Connect the mobile device to your computer using a USB cable.
  3. Open your project in your Unity Editor.
  4. In your Unity Editor, select File > Build Settings, and ensure that iOS is selected. (The Unity logo next to a platform name indicates it’s selected.)
    If iOS is not selected, select it and then select Switch Platform.
  5. In your Unity Editor, select Edit > Project Settings > Player. This opens the Project Settings window.
  6. In the Inspector window, select Settings for iOS (the iPhone icon) > Other Settings.
  7. In the Configuration section of the Inspector window, locate Target SDK and select Device SDK.
  8. Still in the Configuration section, locate Target minimum iOS version and input 10.0.
  9. In your Unity Editor, select Assets > Fps > Prefabs > iOSClientWorker.
  10. In the Inspector pane, enter your local IP address into the IOS Worker Connector (Script) > Forced Ip Address field.
  11. Still in the Inspector pane, ensure that the should connect locally checkbox is checked.
  12. Build your workers from the SpatialOS menu by selecting Build for local > All workers.
  13. 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.
  14. In a terminal window from the root folder of your SpatialOS project, run: spatial local launch --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 as you would normally, 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.
  15. In Finder, navigate to /workers/unity/build/worker/ and locate the .xcodeproj that corresponds to your iOS client-worker, it may be in a sub-folder.
    Open it in Xcode.
  16. In XCode, in the Navigation Area, select the Project root.
  17. Still in XCode, now in the Editor Area, go to Build Settings > Packaging > Project Bundle Identifier and input a unique string.
  18. Still in the Editor Area, select General > Signing and sign the project.
    For more information, see Code signing and provisioning [Apple Documentation].
  19. Still in XCode, select the Play button in the top left of the window. This will install the game as an app on your device and start it.
  20. 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 select Connect.
  21. Play the game on your mobile device.
  22. When you’re done:
    • Exit the app on your device.
    • In XCode, select the Play button to stop your the game running.
    • In the terminal window that’s running the SpatialOS process, enter Ctrl+C to stop the process.

Search results

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums