Archived Documentation

This version of the guide is out of date. Click here for the latest version.

Unity (Gear VR) Getting Started

The Avatar Unity packages contain several prefabs you can drop into your existing Unity projects. This tutorial shows you how to start using them.

Download the Oculus Avatars SDK

The SDK is packaged in a .zip archive file on our developer website.

  1. Download the Oculus Avatars SDK .zip from https://developer.oculus.com/downloads/.
  2. If you do not have the Oculus Utilities for Unity 5, download its .zip file too.
  3. Extract the contents of the .zip archive files to your local drive.

Set Up Unity for Oculus Avatar Gear VR Development

The set up includes importing the Oculus Unity packages and also setting up Unity for Android development and debugging.

  1. Create a New Project in Unity named "gearvr-avatar".
  2. Click File > Build Settings and select Android. Download and install Unity Android Support and then restart Unity if necessary.
  3. Click Switch Platform to switch to Android platform.
  4. Click Add Open Scenes.
  5. Set Texture Compression to ASTC.
  6. Click Edit > Project Settings > Player, click the little Android Settings robot, and then set the following options:
    1. Select the Virtual Reality Supported check box.
    2. In Bundle Identifier, enter a unique package name.
    3. Set Minimum API Level to Android 5.0 'Lollipop' (API level 21).
    4. Set Install Location to Automatic.
  7. Import the Oculus Avatars (OvrAvatar.unityPackage) and Oculus Utilities (OculusUtilities.unitypackage) packages. For each package:
    1. Click Assets > Import Package > Custom Package.
    2. Select the package file from your local drive.
    3. Click All and then click Import.
  8. Connect your Android device to your computer.
  9. Create an Oculus Signature File for your Android device at https://dashboard.oculus.com/tools/osig-generator/and then copy it to the folder gearvr-avatar/Assets/Plugins/Android/assets. Create this folder if it doesn't exist.

Adding the VR Camera

Because the avatar has a default height of 170 cm, we should raise our VR camera rig to the same height.

  1. Delete Main Camera from your scene and then drag OVRCameraRig from OVR > PreFabs.
  2. Set the Position transform on OVRCameraRig to X:0,Y:1.70, Z:0.

Adding an Avatar

As the player cannot see his or her own Gear VR avatar, Gear VR avatars should all be of the "third person" type. To make sure the avatar is visible, we can place the avatar 50cm in front of the camera, and rotate the avatar 180 degrees so that its front faces us.

Note: The "local" in the prefab name "LocalAvatar" refers to how the avatar object gets its motion data. "Local" means the avatar object is driven by the local headset orientation.
  1. Drag OvrAvatar > Content > Prefabs > LocalAvatar to the Hierarchy window.
  2. In the Inspector, clear the Show First Person check box and select the Show Third Person check box.
  3. Select the Combine Meshes check box. This reduces total draw calls per frame per avatar to 6 from 22. Gear VR apps typically need to stay within 50 to 100 draw calls per frame.
  4. Set the Position transform on LocalAvatar to X:0, Y:0,Z:0.50.
  5. Set the Rotation transform on LocalAvatar to X:0, Y:180, Z:0.
  6. Click File > Build & Run to build an .apk from this scene and have Unity launch it on your Android device.

What to Explore Next?

  • Loading Personalized Avatars

    See Unity Features for instructions on how to modify the sample scenes to retrieve Oculus User IDs and display personalized avatars.

  • Recording and Playing Back Avatar Pose Updates

    Build our RemoteLoopback example scene and read the accompanying write-up in our Unity (Rift) Getting Started topic.