Oculus Quest Build Using Unity 2019.1.6f1 + VRTK 4.0 + Oculus Integration 1.40

VERSIONS

Unity Version : 2019.1.6f1
VRTK Version : 4.0 Beta
Oculus Integraton Version : 1.40


NOTE

This documentation was created as a guide to build a basic working application in Unity for the Oculus Quest using VRTK and Oculus Integration.
This documentation was created as of September 2019 based on the Versions of Unity & SDKs as mentioned above, the steps provided below may not work for future releases. This documentation also assumes that you have experience with Unity and have all the correct Modules installed in order for this to work correctly.

Useful Links
VRTK Documentation
Input for Oculus


CONTENTS

  1. Steps
  2. Project Settings
  3. VRTKOculusImplementation
  4. OVRCameraRig
  5. Linked Alias Association Collection
  6. OVR Anchor Velocity Estimator
  7. Local Avatar
  8. Tracked Alias
  9. Interactors
  10. Assigning Buttons
  11. Interactable
  12. Oculus-ID
  13. ADB-Setup
  14. Building The Application

STEPS

  • Create a new empty Project in Unity
  • Change the Platform from Windows PC, Mac & Linux Standalone to Android by going to (File > Build Settings or Ctrl + Shift + B). Select Android and press Switch Platform.
This is the Build Settings once you have Switch Platform to Android.
  • Import Oculus Integration from the Asset Store (Window > Asset Store or Ctrl + 9)
  • Search for Oculus Integration in the search bar and Import.
Import the Oculus Integration into your project.
  • Once Oculus Integration has been imported a pop up will appear asking you to restart your Unity, press Restart.
  • When the Project restart another pop up will appear asking you to add Key Bindings press Okay as this is required by VRTK later on.
  • To check if the Key Bindings has been imported, go to (Edit > Project Settings > Input > Axes)
Your Input Key Bindings should have the additional bindings automatically.

PROJECT SETTINGS

  • The next steps involve the settings with Player Settings.
  • Go to (Edit > Project Settings > Player)
  • Change the Company Name and Product Name to your preference. It is recommended that you do not simply change these names in the future as it might cause errors upon Building.
Change the Company Name and Product Name to your preference.
  • Click on Other Settings to expand it. In the Auto Graphics API select Vulkan and click on the [ – ] symbol to delete it.
Delete Vulkan from the Graphics APIs list.
  • Under Identification, change the Package Name to match the Company Name & Product Name that you have set earlier. For the Minimum API Level, change it to Android 4.4 ‘KitKat’ (API Level 19)
Change the Package Name and Minimum API Level.
  • Next is expand XR Settings, check Virtual Reality Supported. Click on the [ + ] symbol and add Oculus.
Add Oculus as your Virtual Reality SDKs.

VRTKOculusImplementation.unitypackage

  • At this point, the basic setup is completed, next we have to import the additional Packages to implement VRTK. I have prepared the necessary package called VRTKOculusImplementation.unitypackage for your perusal.
  • This package includes scripts that will be used in the project. These scripts are required in order to integrate VRTK with Oculus Integration.
  • Download the packages in the following link, and export the package into your Unity Project.
    Download Here
  • To export the .unitypackage go to (Assets > Import Package > Custom Package) Find the .unitypackage that you have downloaded and click Open.
Import VRTKOculusImplementation.unitypackage to your Unity Project.
  • Once everything has been imported your Assets folder should look as below.
Current Assets Folder.

OVRCameraRig

  • Now we are ready to setup. In your Assets folder, open the Scenes folder, inside the is a scene called Sample Scene, double click on that scene to open it. You can rename the scene to your own preference.
  • In your Project Panel, search for OVRCameraRig, drag the OVRCameraRig Prefab into your Hierarchy.
Drag OVRCameraRig into Hierarchy.
  • Select OVRCameraRig in the Hierarchy, in the Inspector change the Element under OVRManager from Gear VR Or Go to Quest and the Tracking Origin Type to Floor Level.
Change the Element and Tracking Origin Type.

Linked Alias Association Collection

  • Scroll down until you reach the bottom of the Inspector and press Add Component button, search for Linked Alias Association Collection in the search bar and click on it. Your OVRCameraRig now should have a Linked Alias Association Collection as a component.
Linked Alias Association Collection script added to OVRCameraRig
  • Expand OVRCameraRig in the Hierarchy, expand TrackingSpace and drag the following inside the Linked Alias Association Collection.
Assigning the Linked Alias Association Collection properties.

OVR Anchor Velocity Estimator

  • We still have some missing properties to Linked Alias Association Collection. To fix this we have to add some components called OVR Anchor Velocity Estimator to the CenterEyeAnchor, LeftHandAnchor and RightHandAnchor.
  • Under TrackingSpace in the Hierarchy, select CenterEyeAnchor, LeftHandAnchor and RightHandAnchor. With all 3 GameObjects selected, press Add Component button in the Inspector and search for OVR Anchor Velocity Estimator and click on it. Now all three of the selected GameObjects will have the OVR Anchor Velocity Estimator as their new component.
  • With all the 3 GameObjects selected, drag the OVRCameraRig GameObject to the Relative To slot in the OVR Anchor Velocity Estimator.
Drag the OVRCameraRig to the Relative To slot.
  • For the Tracked Game Object slot, simply drag the GameObject itself from the hierarchy inside the slot in their respective inspector as below:
Drag CenterEyeAnchor to Tracked Game Object
Drag LeftHandAnchor to Tracked Game Object
Drag RightHandAnchor to Tracked Game Object

Local Avatar

  • In your Project Panel, search for LocalAvatar, drag the LocalAvatar Prefab as a child of your OVRCameraRig in the Hierarchy.
Drag LocalAvatar and put under OVRCameraRig.
  • Select LocalAvatar in the Hierarchy, in the Inspector, scroll down until you find Other. Set the settings as below:
Disable Can Own Microphone and Enable Laughter.

Tracked Alias

  • Now we need to set the Tracked Alias to identify which Head Mounted Device we are using.
  • In your Project Panel, search for TrackedAlias, drag the Tracked Alias prefab into the Hierarchy.
  • In the TrackedAlias Inspector, select Elements, set the size to 1 and drag the OVRCameraRig inside the Element as below:
Settings for TrackedAlias.

Interactors

  • At this point the setup for the HMD is ready, but we do need to put interactions to be able to interact with our environment.
  • In your Project Panel, search for Interactor, drag the Interactor prefab as a child into the LeftControllerAlias and RightControllerAlias inside the TrackedAlias > Aliases > LeftControllerAlias & TrackedAlias > Aliases > RightControllerAlias in the Hierarchy.
  • Feel free to hide the ExampleAvatar (the Rectangular GameObject) if you wanted to, to hide the ExampleAvatar, simply open the Interactor > ColliderContainer > ExampleAvatar. Select Example Avatar and disable the GameObject.
Setting up the Interactors.
  • Notice in the Interactor’s Inspector, there is a script called Interactor Facade which is one of the component of the Interactor.
  • Inside there are Interactor Settings which we have to configure in order for the Interactor to work.
Interactor Facade Settings.
  • For this we have to assign some buttons in order for it to work.

Assigning Buttons

  • Before we start we need to understand the layout of the Quest Controllers Input Map in Unity. Refer to the image below. You can also refer to Input for Oculus .
Oculus Quest Input Map.
  • To create a button to grab an object, first we need to create an empty GameObject. Reset its transform so that the position is based at 0,0,0.
  • Rename it to SecondaryHandTriggerAction.
  • Notice that Secondary is for the Right Hand Controller. And we are going to assign an action when we press the Hand Trigger Button on the controller.
  • Select the SecondaryHandTriggerAction in the Hierarchy, in the Inspector, click the Add Component button.
  • Search for OVR Input Button Action Script and select it.
  • In the OVR Input Button Action component, change the Controller to Touch, and Button to Secondary Hand Trigger.
SecondaryHandTriggerAction Settings.
  • Expand Tracked Alias > Aliases > RightControllerAlias > Interactor in the Hierarchy.
  • Assign the SecondaryHandTriggerAction to the Grab Action slot under Interactor Facade.
  • Assign the RightControllerAlias to the Velocity Tracker slot.
Assigning the Interactor.
  • Expand Tracked Alias > Aliases > RightControllerAlias > Interactor in the Hierarchy.
  • Assign the SecondaryHandTriggerAction to the Grab Action slot under Interactor Facade.
  • Assign the RightControllerAlias to the Velocity Tracker slot.

Interactables

  • As of now we have an interactor and we have assigned a button to do the interactions. Now we need to add an interactable object.
  • In your Project Panel, search for Interactable.Primary_Grab.Secondary_Swap, drag the Interactable.Primary_Grab.Secondary_Swap prefab in the Hierarchy.
Adding an object to be interacted.
  • Adjust the Position of the Gameobject to (0,1,1).
  • Your scene should now have a cube to represent the interactable object.
Change the Position of the prefab.
  • You also need to change the scale of the prefab, make sure to change the scale of the DefaultMesh inside the main parent.
  • Go to your Hierarchy, select Interactable.Primary_Grab.Secondary_Swap > Meshes > DefaultMesh and change the scale to (0.5,0.5,0.5).
Change the Scale of the DefaultMesh.
  • Now, add a plane and rename it to ground. Adjust the scale to 10,10,10.
Ground scale set to 10,10,10.
  • Create a material by right clicking in your Project panel, (Create > Material).
  • Name the material to ground.
  • Click on the Ground Material in your Project Panel and change the Albedo color to your liking in the Inspector.
  • Assign the material to the ground by dragging the Material to the Ground GameObject in the Scene.
Change Ground color.
  • We’re almost ready to build our application.

Oculus ID

  • Before building our Application, we need to setup an Oculus ID.
  • Go to https://dashboard.oculus.com/
  • Log In to your account, or create one.
  • Select Create New App.
  • Fill in the required data. Example as below
Choose Oculus Go & Gear VR for the Platform options.
  • Press Submit, you will be redirected.
  • Copy the App ID.
Copy the App ID.
  • In your Unity Editor, Go to (Oculus > Avatars > Edit Settings).
  • In the Inspector insert your Oculus App ID to the Oculus Rift App ID slot and Oculus GO/Quest or Gear VR slot.
Oculus > Avatar > Edit Settings.
OVRAvatarSettings.
  • Next, Go to (Oculus > Platform > Edit Settings).
  • Do the same in the Inspector, insert your Oculus App ID to the Oculus Rift App ID slot and Oculus GO/Quest or Gear VR slot.
Oculus > Platform > Edit Settings .

ADB-Setup


Building The Application

  • Assuming that your have enable sideloading apps to your Oculus Quest.
  • You are now ready to build your application.
  • Go to (File > Build and Run or Ctrl + B)
  • Once the build has finished.
  • Put on your Oculus Quest.
  • Navigate to (Library > Unknown Sources)
  • Find the Package Name of your application that you had set earlier.
  • Make sure to try and grab the Interactable object.
  • Enjoy!
Advertisements

Published by hamdanbasri

Games | Simulation in VR & AR

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: