Since the launch of Apple’s ARKit, there’s been a ton of buzz and amazing demos shared, we recently shared a video on Twitter that showed WRLD working in ARKit. Given the interest we’ve received we decided to lay down steps for anyone who wants to get started with ARKit and WRLD SDK and see for themselves how amazing it is!
Please check the requirements mentioned in the Unity-ARKit-Plugin for the software and hardware required for ARKit.
To get started simply set the platform to iOS on your project and follow the steps below.
Step 1: Import ARKit Unity Plugin
The team at Unity has created a great plugin that allows us to utilize ARKit easily in any Unity projects. Currently it requires that you are using Unity version v5.6.1p1 or later. For detailed documentation please see the download page for the ARKit Plugin.
Step 2: Import WRLD Unity SDK from Asset Store
Download and import the WRLD Unity SDK. If you need a key and then click “Get Key” when prompted or simply click later if you already have one.
Step 3: Modify a couple of files
WRLD SDK is built to be used with real world scale such that 1 unit in Unity is considered 1 meters. You can read more about our coordinate system on our Unity documentation. ARKit however require objects to be quite small, so we will need to scale down our map. In order to do that we need to add a couple of lines of code in our SDK. We will add an API to enable this more seamlessly in future release.
In /Assets/Wrld/Scripts/Streaming/GameObjectFactory.cs go to Method CreateGameObject and Add
In /Assets/Wrld/Scripts/Streaming/GameObjectRepository.cs go to Constructor and Add
Step 4: Making a scene for ARKit
Create a new scene so we can set up ARKit and follow the steps below.
- Create a new GameObject called CameraParent and make Main Camera its child.
- On Main Camera make the following changes
- Building Control system status
- Set Clear Flags to Depth Only
- Set Field of View to 60
- Set Clipping PLanes to 0.1 Near and 30 Far
- Set Depth to 0
- Add Component UnityARVideo (In Clear Material set YUVMaterial)
- Add Component UnityARCameraNearFar
- See the image below for reference
- Create a new GameObject and name it ARCameraManager
- Add Component UnityARCameraManager
- In Camera field drag drop our Main Camera
- Save your scene.
And that’s it!, ARKit is ready to be used.
Step 5: Setting up WRLD SDK
Now that we have ARKit ready, we can start setting up our map. Follow the instructions below.
- Setup iOS Assets through the Assets Menu.
- Create a new Camera and name it Streaming Camera. We will use this camera to stream our map. Disable the Camera component as we will not be using this to draw anything.
- Set Y position to 1000. This means we will be streaming from an altitude of 1000 Meters.
- Set X rotation to 90 so our StreamingCamera looks towards ground.
- Remove all the extra components such as AudioListener etc
- Set Near to 10 and Far to 5000
- Create a new GameObject and name it WRLD Map.
- Add component WRLD Map
- Set your API Key
- Set Camera to StreamingCamera
- Set scale to 0.001
- Set y position to -0.3
- Set the Latitude to 40.748376 and Longitude to -73.985632
- Save your scene.
We are now ready to view WRLD Map in ARKit.
Step 6: Build Unity Project
We have completed all the necessary steps, we can finally build our xcode project and see it running on an iOS Device.
If you are having trouble with compiling libStreamAlpha.a then just set “Enable Bitcode” to No in Xcode Build Settings. Also make sure that you add Camera Usage Description for iOS in Player Settings->Other Settings.
If you are having trouble getting shadows then you might need to go to quality settings and set the Shadow distance to 2 and Shadow Near Planes to 0.01.
Step 7: Further improvements
Now that you have a working project with WRLD in ARKit you can start to build new exciting things. Check out our next post that covers stencil masks and how to show a map on a surface within a certain area.
We are excited to see what you build with WRLD so feel free to reach out and share with us @wrld3d, #madewithWRLD.
If you have any questions, please reach out to us at email@example.com.