To create a VR smartphone application with 6 degree of freedom, you can enable 6Dof in a small area with Google Daydream: https://developers.google.com/vr/develop/unity/3dof-to-6dof
However, if you want to use 6DoF within an virtually unlimited space, or with Google Cardboard, you can use this hacking technique: combine it with ARCore tracking. We describe how to do that in this tutorial. You can use this as a starting point as well with your own rendering: 1) apply your rendering to the ARCore Camera OR 2) re-use the ARCore camera transform (position and rotation) for your own custom camera.
This technique is incredibly convenient to do research on VR remolty. You just need a compatible smartphone and a smartphone VR headset for the stereoscopic view ( /!\ to work with this technique, you need to ensure the smartphone camera is not hidden).
In this tutorial, we consider you know how to generate an Android application Android SDK 7.0 (API Level 24) from a Unity project, and you have the set up to build such app . Otherwise, you can check the tutorial here: https://sites.google.com/ensc.fr/laurenthevin/scientific-mediation/accessible-treasure-hunting/tutorial-accessible-treasure-hunting from the section "Create the smartphone app"
You use should Unity 2017.4.34f1 or later. In this tutorial, I use Unity 2019.2.10f1 (64-bit)
A smartphone compatible with AR core (https://developers.google.com/ar/discover/supported-devices)
Official quick starting guide for ARCore: https://developers.google.com/ar/develop/unity/quickstart-android
To create a 6DoF VR smartphone app:
Create a new project
For Unity 2019: incuding Multiplayer HLAPI and Legacy Input Helper packages from the package manager
Download and import arcore-unity-sdk unitypackage from here: https://github.com/google-ar/arcore-unity-sdk/releases
Include the prefab “ARCore Device” (that will be the camera) in your scene and delete other game objects
Create your scene
Set the player settings (Android tab) as follow:
UNcheck Auto Graphics API in rendering (remove Vulkan if included),
change "Package Name",
set the minimum API level to Android 7.0 Nougat or higher
check "ARCore supported" in XR Settings
check "Virtual Reality supported" and add Cardboard
Generate your app
Launch your app, and use it with a smartphone VR headset that does not hide the back camera of your smartphone.