How to Use ARKit and Unity to Create 6DOF Mobile VR

Photo by Scott Webb on Unsplash

Recently I had the not so original idea of using tracking enabled Apple’s ARKit in order to create a 6DOF mobile VR experience. After some research partnered with a healthy dose of trial and error, I was able to develop a method that allowed me to do this using Unity. While there are still problems with it, mainly that the experience is somewhat laggy with bugging tracking, I wanted to share the procedure in the hopes that others could replicate it and improve upon it. I personally think that the ability to walk around in mobile VR will help people to create more immersive experiences that will more accessible to the general public thanks to initiatives like Google Cardboard. Hopefully, if you can get this to work you can end up with something like this.

Finished Product

There is no code involved in this, just the correct environment and tools.

1. Set-Up

This is what I used in order to create this demo, but there is a chance that other versions of Unity or Xcode could still be used to make this work. It is also important to note that this tutorial assumes that you already have a Unity environment that works with iOS. If not, refer to this tutorial in order to get the environment ready.

  • Unity 2018.2.21f1
  • Xcode 10 or greater
  • iPhone running iOS 12.0 or later
  • Compatible Google Cardboard Viewer

2. Preparing the Unity Environment

  1. Create a 3D Unity Project through the Unity Hub.
  2. Change Platform to iOS in File > Build Settings using the switch platform button on the left once iOS is selected
Build Settings
  1. Then hit the Player Settings button beside the Switch Platform button.
  2. In the Other Settings section, check “Requires ARKit Support
  3. Change the target minimum iOS version to 12.0
  4. Change the Architecture to ARM64
  5. Add a Bundle Identifier in the Other Settings section. This is going to be something like com.CompanyName.ProductName; change it to something unique.
Player Settings

3. Installing Packages

  1. Go to Window > Package Manager
  2. Click “All” then install AR Foundation and ARKit XR Plugin
Libraries to install
  1. Then go to the GVR page and download the GVR SDK for Unity
  2. Install the SDK into the Unity Project using the file in the unzipped folder

If Unity requests an API update during the install allow it

Unity Package to Install

4. Setting the Scene

Delete the Main Camera

Right-click in the scene hierarchy, go down to XR on the menu, then click on AR Session to add it to the scene

AR Session Location

Inside the Project Hierarchy go to Assets > Google VR > Prefabs and drag the GvrMain Prefab into the project

GvrMain Location

Disable tracking on the head component in GvrMain > Head within the scene hierarchy

Disabling Tracking

With GvrMain selected, click add component and select (this may need to be searched) the tracked pose driver from the XR folder

Adding Tracked Pose Driver

Switch the pose source on the tracked pose driver to the color camera

Changing Positional Source

Create a cube

Creating a Cube

Then on the cube change the position Z to 1 and change the X, Y, Z of scale to 0.1

Changing the Size of the Cube

5. Finishing Up

Finally, save the scene, then build it with either ⌘B or going to File > Build and Run (if asked to strip ARKit allow it). Make sure that the iPhone is plugged into the computer in order to install the app. Once the app is running, slide the phone into the Google Cardboard viewers and if all goes well it should look like the demo above. Just note that the cube will spawn 0.1 meters in front of where ever the phone opens the app. Hopefully, this was useful, so go forth and create new 6DOF experiences.




👋 My musings here are basically a public stream-of-consciousness journal, so please forgive my writing: it’s getting better, I promise.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Customize NavigationView bar background color in SwiftUI

Long Jump Run Up Construction in Elsing #Long #Jump #Runway #Installation #Elsing

Choosing an IoT platform: what to think about

4 Tips to Improve your Coding Skills

Logging data using .NET Core and Amazon Web Services

How to fix an unresponsive MacBook trackpad or Magic Trackpad 2

Deploying a real time notification system on Kubernetes : Part 1

How to create a COVID dashboard web application with Python

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Connor Sparks

Connor Sparks

👋 My musings here are basically a public stream-of-consciousness journal, so please forgive my writing: it’s getting better, I promise.

More from Medium

Top 10 Virtual Reality Workout Apps

Making VR Games with Oculus Quest 2

ThreeJS — Importing .glb Ready Player Me Avatar

VR For Flatscreen Unreal Engine Games | UnrealVR #0