Difference between revisions of "Using the Vive Trackers in Unity"
(16 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
== Before getting started: == | == Before getting started: == | ||
− | Each vive tracker requires its own USB dongle. The number of USB dongles that you can use at one time is limited by the USB bandwidth on the motherboard of the computer. In the HTC.VIVE space in the Interaction Station there is an extra USB PCI card installed that should allow you to connect all the of the dongles at the same time. The trackers seem to work best with the dongles in line of sight from the tracker, so it’s recommended to use the USB extensions that come with the dongles. In most cases the trackers will not work if the headset isn’t connected, there are hacks to get around this but the easiest setup is to connect the headset. | + | Each vive tracker requires its own USB dongle. The number of USB dongles that you can use at one time is limited by the USB bandwidth on the motherboard of the computer. In the HTC.VIVE space in the Interaction Station there is an extra USB PCI card installed that should allow you to connect all the of the dongles at the same time. The trackers seem to work best with the dongles in line of sight from the tracker, so it’s recommended to use the USB extensions that come with the dongles. In most cases the trackers will not work if the headset isn’t connected, there are hacks to get around this but the easiest setup is to connect the headset.<br/> |
[[File:vive_trackers_01_dongle.png]] | [[File:vive_trackers_01_dongle.png]] | ||
Line 11: | Line 11: | ||
== In the Steam VR app: == | == In the Steam VR app: == | ||
− | 1.)Pair trackers in SteamVR | + | 1.) Pair trackers in SteamVR |
https://www.vive.com/us/support/wireless-tracker/category_howto/pairing-vive-tracker.html | https://www.vive.com/us/support/wireless-tracker/category_howto/pairing-vive-tracker.html | ||
− | 2.)Once the tracker is paired, right click the tracker and select manage trackers | + | 2.) Once the tracker is paired, right click the tracker and select manage trackers<br/> |
+ | <br/> | ||
+ | [[File:vive_trackers_02_manage.png | 500px]]<br/> | ||
+ | <br/> | ||
− | 3.)In the manage tackers section assign tracker to a body part (knees and elbows don’t work yet, so don’t use those) | + | |
+ | 3.) In the manage tackers section assign tracker to a body part (knees and elbows don’t work yet, so don’t use those)<br/> | ||
+ | <br/> | ||
+ | [[File:vive_trackers_03_assign.png | 500px]] | ||
== In Unity: == | == In Unity: == | ||
Line 27: | Line 33: | ||
'''2.)Generate Controller Bindings:''' <br/> | '''2.)Generate Controller Bindings:''' <br/> | ||
-select window/steamvr input<br/> | -select window/steamvr input<br/> | ||
+ | |||
+ | [[File:steamvr_input.png]] | ||
+ | |||
-click save and generate binding<br/> | -click save and generate binding<br/> | ||
+ | |||
+ | [[File:Vive_trackers_saveandgenerate.png | 500px]] | ||
+ | |||
-click open binding ui (you may have to select the binding for your specific unity project)<br/> | -click open binding ui (you may have to select the binding for your specific unity project)<br/> | ||
<br/> | <br/> | ||
+ | [[File:Vive_trackers_openbinding.png | 500px]] | ||
+ | |||
+ | <br/> | ||
+ | '''3.) Manage Bindings'''<br/> | ||
-in binding ui click on current controller to tracker assigned to body part<br/> | -in binding ui click on current controller to tracker assigned to body part<br/> | ||
-It will probably show nothing under Current Binding, so you need to "Create New Binding". In there, you either have to Add Action Pose or Edit Action Poses. There, assign Pose to user/foot/left/pose/raw. Make sure to save your binding.<br/> | -It will probably show nothing under Current Binding, so you need to "Create New Binding". In there, you either have to Add Action Pose or Edit Action Poses. There, assign Pose to user/foot/left/pose/raw. Make sure to save your binding.<br/> | ||
Line 40: | Line 56: | ||
-To get an idea of how we might use the trackers in Unity, we can take a look at the SteamVR camera rig. Remove the main camera from your scene and add the camera rig to your scene (Assets/steamVR/Prefabs/[Camera Rig]). If you take a look at controller left game object, it is just a empty game object with a steamvr_behaviour_pose script attached to it. If you take a look at the input source it is currently assigned to the left hand, but you can select a number of other body parts as the input source. The controller left gameObject has a child object with a steamvr_render_model script attached to it. This will handle rendering the model of the controller.<br/> | -To get an idea of how we might use the trackers in Unity, we can take a look at the SteamVR camera rig. Remove the main camera from your scene and add the camera rig to your scene (Assets/steamVR/Prefabs/[Camera Rig]). If you take a look at controller left game object, it is just a empty game object with a steamvr_behaviour_pose script attached to it. If you take a look at the input source it is currently assigned to the left hand, but you can select a number of other body parts as the input source. The controller left gameObject has a child object with a steamvr_render_model script attached to it. This will handle rendering the model of the controller.<br/> | ||
− | <br/> | + | [[File:steamvr_controller_left.png|500px]] [[File:steamvr_controller_left_model.png|500px]] |
+ | <br/><br/><br/> | ||
-to add our own trackers into the scene add an empty game object as a child of the [camera rig], rename it to your body part that you are tracking ie. left foot <br/><br/> | -to add our own trackers into the scene add an empty game object as a child of the [camera rig], rename it to your body part that you are tracking ie. left foot <br/><br/> | ||
-add a steamvr_behavior_pose component to the game object and change the input source to left foot<br/><br/> | -add a steamvr_behavior_pose component to the game object and change the input source to left foot<br/><br/> | ||
+ | |||
+ | [[File:steamvr_left_foot.png | 500px ]] | ||
+ | |||
+ | [[File:steamvr_left_foot_source.png | 500px]] | ||
+ | |||
-add a child game object to your left foot, and rename to model <br/><br/> | -add a child game object to your left foot, and rename to model <br/><br/> | ||
− | -add a steamvr_render_model component to the model game object. You can leave all the settings as default. <br/><br/> | + | |
+ | -add a steamvr_render_model component to the model game object. You can leave all the settings as default. <br/> | ||
+ | |||
+ | [[File:steamvr_left_food_model.png | 500px]] | ||
+ | |||
+ | <br/> | ||
<br/> | <br/> | ||
-and voila that should be enough to have a tracker in your scene complete with a render model for the tracker. You can repeat these steps to add additional trackers. | -and voila that should be enough to have a tracker in your scene complete with a render model for the tracker. You can repeat these steps to add additional trackers. | ||
Line 52: | Line 79: | ||
https://github.com/ViveSoftware/ViveInputUtility-Unity/wiki/SteamVR-Input-System-Compatibility<br/> | https://github.com/ViveSoftware/ViveInputUtility-Unity/wiki/SteamVR-Input-System-Compatibility<br/> | ||
https://medium.com/@sarthakghosh/a-complete-guide-to-the-steamvr-2-0-input-system-in-unity-380e3b1b3311<br/> | https://medium.com/@sarthakghosh/a-complete-guide-to-the-steamvr-2-0-input-system-in-unity-380e3b1b3311<br/> | ||
+ | |||
+ | [[Category:Virtual Reality]] [[Category:Motion Tracking]][[Category:Unity]] |
Latest revision as of 12:44, 21 November 2022
Before getting started:
Each vive tracker requires its own USB dongle. The number of USB dongles that you can use at one time is limited by the USB bandwidth on the motherboard of the computer. In the HTC.VIVE space in the Interaction Station there is an extra USB PCI card installed that should allow you to connect all the of the dongles at the same time. The trackers seem to work best with the dongles in line of sight from the tracker, so it’s recommended to use the USB extensions that come with the dongles. In most cases the trackers will not work if the headset isn’t connected, there are hacks to get around this but the easiest setup is to connect the headset.
The trackers have a standard 1/4” camera thread on the underside and can be attached to tripods. In the interaction station we also have a few different straps that allow the trackers to be worn on the body, for example on your waist, on your feet or on your hands.
PLEASE NOTE this guide was written for SteamVR 1.10.28, Unity 2019.2 and SteamVR Unity Plugin v2.5.0. Things change rapidly in the VR world so you may have to seek out a more up-to-date guide.
In the Steam VR app:
1.) Pair trackers in SteamVR
https://www.vive.com/us/support/wireless-tracker/category_howto/pairing-vive-tracker.html
2.) Once the tracker is paired, right click the tracker and select manage trackers
3.) In the manage tackers section assign tracker to a body part (knees and elbows don’t work yet, so don’t use those)
In Unity:
1.)Import Steam VR Unity package (from GitHub or Asset Store)
https://assetstore.unity.com/packages/tools/integration/steamvr-plugin-32647
https://github.com/ValveSoftware/steamvr_unity_plugin
2.)Generate Controller Bindings:
-select window/steamvr input
-click save and generate binding
-click open binding ui (you may have to select the binding for your specific unity project)
3.) Manage Bindings
-in binding ui click on current controller to tracker assigned to body part
-It will probably show nothing under Current Binding, so you need to "Create New Binding". In there, you either have to Add Action Pose or Edit Action Poses. There, assign Pose to user/foot/left/pose/raw. Make sure to save your binding.
-repeat for each additional body part
-now you will have bindings for each tracker.
Using the trackers inside of Unity:
-To get an idea of how we might use the trackers in Unity, we can take a look at the SteamVR camera rig. Remove the main camera from your scene and add the camera rig to your scene (Assets/steamVR/Prefabs/[Camera Rig]). If you take a look at controller left game object, it is just a empty game object with a steamvr_behaviour_pose script attached to it. If you take a look at the input source it is currently assigned to the left hand, but you can select a number of other body parts as the input source. The controller left gameObject has a child object with a steamvr_render_model script attached to it. This will handle rendering the model of the controller.
-to add our own trackers into the scene add an empty game object as a child of the [camera rig], rename it to your body part that you are tracking ie. left foot
-add a steamvr_behavior_pose component to the game object and change the input source to left foot
-add a child game object to your left foot, and rename to model
-add a steamvr_render_model component to the model game object. You can leave all the settings as default.
-and voila that should be enough to have a tracker in your scene complete with a render model for the tracker. You can repeat these steps to add additional trackers.
More info:
https://github.com/ViveSoftware/ViveInputUtility-Unity/wiki/SteamVR-Input-System-Compatibility
https://medium.com/@sarthakghosh/a-complete-guide-to-the-steamvr-2-0-input-system-in-unity-380e3b1b3311