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 |
|
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 CloudARPin
s, similar to ARPin
s.
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:
Download arcore-unreal-sdk-1.7.0.zip from the ARCore for Unreal SDK GitHub repo and extract it.
–or–
Clone the repository with the following command:
git clone https://github.com/google-ar/arcore-unreal-sdk.git
Open the sample app
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 Anchor API key.
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.
Enable the ARCore Cloud Anchor API for your Google Cloud Platform project.
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.
After installation completes, look for an app called CloudARPin on your phone and launch it.
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.
Tap Host to enter hosting mode.
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 theARPin
'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 theCloudARPin
'sCloudID
, after the hosting request succeeds.
- The app places an Andy Android object on the plane and attaches it to an
(Optional) While still in hosting mode, you can repeat the previous step to host additional
CloudARPin
s.Tap Cancel to exit hosting mode.
Select a previously returned
CloudARPin
ID and tap Resolve to add previously hostedCloudARPin
s to your scene.- A new
CloudARPin
is created with its tracking state set toPaused
. - A resolve request is sent to the Google Cloud Anchor service.
- The resolve request includes a hosted
CloudARPin
ID. If the ID matches a hostedCloudARPin
, the server returns the transform of theCloudARPin
in your local coordinates. - The sample app uses the transform to render Andy Android objects attached
to the resolved
CloudARPin
.
- A new
(Optional) Tap Cancel and repeat the previous step to resolve additional
CloudARPin
s.