HTC Vive

From ETC Public Wiki
Jump to: navigation, search

HTC Vive is a virtual reality headset that uses "roomscale" tracking that allows the player to move in 3D space. It uses motion-tracked handheld controllers to interact with the environment. As a part of the BVW course, students will be using HTC VIVE Tracker VR Object Tracker and Vive Controllers.

Important Information

  • The Vive Lighthouse 2.0 will only work with Vive Trackers from 2018 or later. Any Trackers prior to that will not track using the Lighthouse 2.0.

Getting Started

Basic setup

  1. Open Unity Project
  2. Go to Edit -> Project Settings -> Player
  3. Click on XR Settings in the Inspector
  4. Check Virtual Reality Supported
  5. Remove Oculus if it exists in the list under Virtual Reality SDKs (This can be done by selecting Oculus and hitting the minus sign at the bottom right)
  6. Make sure OpenVR has been added under Virtual Reality SDKs (If you don't see it, hit the plus sign at the bottom right and select it from the list)
  7. Download Steam VR plugin from asset store
  8. Import it into your project, and click on "I Made A Backup", and click on "Accept All"

For SteamVR Plugin 2.0:

  1. When you hit play and run it, you'll notice a steamVR message that reads "It looks like you haven't generated actions for SteamVR Inmput yet. Would you like to open SteamVR Input window". Click on yes.
  2. This opens up a SteamVR input window. Click on Save and Generate at the end to generate action set classes. (new update requires you to do so)
  3. Now when you run it, it doesn't pop up an error message

Scene Setup

  1. After import is complete, delete "MainCamera" from the hierarchy
  2. From your project window, select Assets -> SteamVR -> Prefabs
  3. Drag [CameraRig] and [SteamVR] into your hierarchy
  4. Now you can get tracking information from controllers!

Using Vive Controllers

See the commented code snippet below

// get a reference to the Vive controller
SteamVR_Controller.Device myController = SteamVR_Controller.Input(index);

// then you can get inputs from the controller by calling methods on it
bool isHairTriggerDown = myController.GetHairTriggerDown();
bool isHairTriggerUp = myController.GetHairTriggerUp();

// you are encouraged to look into the "Device" script to see what kind of functionalities it provides
// so you might find things like this
bool isGripDown = myController.GetPressDown(EVRButtonId.k_EButton_Grip);
Vector2 touchPad = myController.GetAxis(EVRButtonId.k_EButton_SteamVR_Touchpad);

Tracker setup in Unity

  1. Import TrackedObject Script from here (This script only works for two trackers which is the requirement for Round 1/2)
  2. Create an empty GameObject (or, to be able to see it in the game, you can create a sphere)
  3. Add "TrackedObject" component to it, and set the component's TrackedDevice to "Tracker1" or "Tracker2"
  4. Each device correspond to a tracker but the mapping of tracked GameObject to physical trackers may not remain the same

In play mode, tracking information will be send to the "SteamVR_TrackedObject" component, and will be used to modify the position and rotation of that GameObj

Notes and tips:

  1. Rendering the tracker: Create a child GameObject under the tracked GameObject, add "SteamVR_RenderModel" component. In that component, set "ModelOverride" to "{htc}vr_tracker_vive_1_0"
  2. To get the best tracking quality, make sure the tracker is always visible to at least one base station
  3. If you see poor render quality, make sure you are not in Steam Menu in the headset. If you are in the menu, press the menu button on the vive controller to exit
  4. If the LED is not green on the tracker, press and hold the button for a few seconds until it turns blue and then green
  5. If the LED is blinking, it means it is pairing with the headset or the dongle

Tutorial Links:

  1. Unity VR Overview
  2. HTC Vive Tutorial
  3. Input for OpenVR Controllers

Programming Information

Testing Vive Worlds

  1. When you are in the bullpen, the easiest way to test your Vive world is using an FPS controller instead of the Camera Rig.
  2. However, make sure that you leave enough time to test in the platform room with actual Vive.

Art (2D & 3D) Information

Sound Information

Design Guidelines & Tips

  • Make sure the props you use do not block the trackers, it will lose tracking
  • It is not a good idea to have players hold the tracker directly in their hand, try using props/gloves and attach the tracker to it
  • Try to use the roomspace (marked by white tape on the floor)
  • If you're disabling the controller models and using your own models (hands, sword etc.), make sure they are placed at a good distance from your body so that it feels natural to the player.
  • Try using spatial sound in VR to take advantage of the roomspace

Example Projects

Previous ETC Projects