Quickstart for Cloud Anchors in Unreal

Use cloud anchors to build AR experiences that Android and iOS users can share. This guide shows you how to:

  • Set up your development environment for cloud anchors
  • Try out hosting and resolving anchors in a sample app

Prerequisites

  • This guide assumes that you have already installed and configured
    Unreal Engine 4.19 with the GoogleARCore plugin 1.3+.

    If not, see the Quickstart for Unreal for installation and setup steps.

  • If you are new to working with anchors, see Working with Anchors for an introduction.

Requirements

To use cloud anchors, you'll need:

Hardware

Targeting What you'll need
Android
iOS
  • One of the following ARKit-compatible iPhones running iOS version 11 or later:
    • iPhone X
    • iPhone 8 and 8 Plus
    • iPhone 7 and 7 Plus
    • iPhone 6S and 6S Plus
    • iPhone SE

  • A USB cable to connect your phone to your development machine

Software

Targeting What you'll need
Android
iOS

Use cloud anchors

Cloud anchor capabilities are included with the GoogleARCoreServices plugin for Unreal.

The following sections show you how to:

  • Set up your development environment for working with cloud anchors
  • Install and try out the sample app

Cloud anchor naming note

Unreal implements cloud anchors as CloudARPins, similar to ARPins. The GoogleARCoreServices plugin for Unreal and the sample app follow this naming convention. This guide will also use the term CloudARPin when referring to cloud anchors in Unreal.

Configure your development environment

Targeting What to do
Android Follow the Unreal Android Quick Start
iOS Follow the Unreal iOS Quick Start

Build Unreal Engine with the GoogleARCore plugin

To use the CloudARPinSample, make sure to build Unreal Engine 4.19 with the GoogleARCore plugin 1.3+ from source code first.

For instructions, see Setting up your development environment in the ARCore Quickstart for Unreal.

Obtain the sample

Obtain the CloudARPinSample using one of the following options:

  • Download the sample project repository and extract it.
  • Clone the repository with the following command:
    git clone https://github.com/google-ar/arcore-unreal-sdk.git

Open the sample app

  1. In the Unreal Editor, open the CloudARPinSample project.

The following sections will show you how to configure the sample to use cloud anchors.

About cloud anchor ID sharing

The CloudARPin sample app uses Unreal’s Networking feature for sharing cloud anchor IDs across a local network.

Review CloudARPinReplicator and ARPlayerController in the CloudARPin sample for implementation details.

You can use a different networking solution in your own apps.

Add an API Key

To use the CloudARPin API in the GoogleARCoreServices plugin in your app, you'll need a Google ARCore Cloud Anchors API key.

  1. Obtain an API Key. See Setting up API keys in the Google Cloud Platform Console Help Center if you are new to working with API keys.

  2. Enable the ARCore Cloud Anchor API for your Google Cloud Platform project.

  3. In Unreal, add your API key to your project:

    • Go to GoogleARCore Project Settings > GoogleARCoreServices.
    • Add the key to the APIKey field.

Package the sample

Targeting What to do
Android Follow the “Deploying” instructions in the Unreal Android Quick Start
iOS Follow the “Deploying” instructions in the Unreal iOS Quick Start

Try out the sample app

Build and run the CloudARPin sample app to try out hosting and resolving cloud anchors. You can try the app on one or more phones.

  1. After installation completes, look for an app called CloudARPin on your phone and launch it.

  2. Start a session on one or more phones:

    Session type What to do
    Single phone
    • Tap Start Session. The session starts and your phone's IP address is displayed on the screen.
    Multiple phones
    • Make sure to connect all phones over a Wi-Fi network that has internet access and allows P2P connection.
    • Use one phone as a host. Launch the app on this phone and tap Start Session. The session starts and your phone's IP address is displayed on the screen.
    • On the other phones:
      • Launch the app and enter the IP address of the host phone.
      • Tap Join after the session starts.

    The sample app launches on your phone(s) and starts detecting planes in front of your camera.

  3. Tap Host to enter hosting mode.

  4. Tap a plane to start hosting a CloudARPin.

    • The app places an Andy Android object on the plane and attaches it to an ARPin.
    • A host request is sent to the Google Cloud Anchor service to create and start hosting a CloudARPin. The host request includes data representing the ARPin's position relative to the visual features near it.
    • A successful host request establishes a hosted CloudARPin here.
    • The app displays a four-digit CloudARPin ID, which is mapped to the CloudARPin's CloudID, after the hosting request succeeds.
  5. (Optional) While still in hosting mode, you can repeat the previous step to host additional CloudARPins.

  6. Tap Cancel to exit hosting mode.

  7. Select a previously returned CloudARPin ID and tap Resolve to add previously hosted CloudARPins to your scene.

    • A new CloudARPin is created with its tracking state set to Paused.
    • A resolve request is sent to the Google Cloud Anchor service.
    • The resolve request includes a hosted CloudARPin ID. If the ID matches a hosted CloudARPin, the server returns the transform of the CloudARPin in your local coordinates.
    • The sample app uses the transform to render Andy Android objects attached to the resolved CloudARPin.
  8. (Optional) Tap Cancel and repeat the previous step to resolve additional CloudARPins.

Next Steps

Send feedback about...