HTC Vive Tutorial for Unity | raywenderlich.com

Learn how to use the HTC Vive with Unity! Grab and throw objects, shoot lasers and teleport around an area.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/9189-htc-vive-tutorial-for-unity

Hello! Iā€™ve just joined, and Iā€™m looking forward to going through the Vive tutorial. I downloaded the materials, but thereā€™s a problem: the Game scene shows up empty, just a blue environment. When I open the ā€œobjectsā€ tab in the hierarchy, all the items inside show up as ā€œMissing Prefabā€. This is the same in both the ā€œStarterā€ and ā€œFinishā€ versions of the project. Am I missing some assets, or do I need to do some preliminary setup in order to view the scene? Please advise. Thanks!

Hi!

That doesnā€™t seem right.
What version of Unity are you using? Iā€™ve tested with both 2018.2 and 2018.3 just now and they both work fine.
It sounds like the 3D models arenā€™t importing correctly. Try right clicking the models in the RW \ Models folder and selecting Reimport, do they load up fine after that?

Cheers!

Thanks for the response! Iā€™m using Unity version 5.6.3. Reimporting those models doesnā€™t solve the problem for me, Iā€™m afraid.

Upgraded to 2018.3 and the assets some through fine. Thanks for the assistance!

Hi there, Thanks a lot for the tutorial!!!

I have only one question about the last part. For the laser pointer ā€˜Teleport Maskā€™ I cannot see the option for ā€˜CanTeleportā€™. Did I miss a configuration?

@blackdragonbe Can you please help with this when you get a chance? Thank you - much appreciated! :]

This needs to be added to the tutorial for 2018.3

Open the Package Manager (Window->Package Manager), select ā€œOpenVRā€ in the package list and click install. Restart Unity

Also the STEAMVR for unity 2018.3 can be found here:

Hey, thanks for the help mate.

Iā€™ve reinstalled the package and plugin, restarted the system but the ā€˜CanTeleportā€™ option still not available.

Once I try teleporting in game, it is very weird. I will keep trying to fix it, I might have missed something simple.

Hi!

CanTeleport is a layer that I included with the project. I know Unity likes to remove those after some version upgrades.
Can you check if the CanTeleport layer exists in the Edit > Project Settings > Tags and Layers menu? It should be assigned to ā€œUser Layer 8ā€. If itā€™s not there, fill in the text field next to User Layer 8 with CanTeleport.

The OpenVR package isnā€™t necessary to follow along with this tutorial, all you need is the most recent version of SteamVR from Github or the Asset Store.

Let me know if you have any questions or issues.

Cheers!
Eric

HI @blackdragonbe

Thanks for the update Iā€™m running through the tutorial now but I have hit a snag. The ActionTest scrip is running correctly but my controllers which having functioning Rigid Bodies are not grabbing the objects. I loaded up the completed version of the tutorial to check for errors but when playing this i see a different issue the controllers vanish as soon as the game starts. I copied your completed script (.cs and .cs.meta) into my project using windows explorer and remove ControllerGrabObject I had made, assuming I misplaced a line of code. the result is the same, the controllers can push objects but can grab them. Just run through the SteamVR and binding inputs steps again with no change. any suggestions of what the issue could be?

Hi Ben,

If the controllers can push the objects, it sounds like the colliders on them arenā€™t marked as triggers. Can you tick the Is Trigger checkboxes of the Box Collider components on both controllers and try again?
I havenā€™t heard of the vanishing controller bug before that you encountered in the final project, Iā€™ll check out what might be the problem.

Cheers,
Eric

EDIT: Ben contacted me by PM, the problem was solved by checking the Is Trigger checkboxes. :smile:

Hi @blackdragonbe

All complete. I noticed two minor things that were not clear or not mentioned and I though Iā€™d let you know. The CanTeleport layer needed to be created (as you mention) but it also needs to be applied to the floor and table without this not only could i not teleport but i could not create/ see my lasers (any everyone loves lasers!). Next you save a little time by applying the same inputs to the Right and Left controllers and then change the hand type of one of the controllers, you also need to change the controller pose which for me applied the same hand to both controller with interesting results (I could control the action and direction of the laser with the opposing hand.
All the best Iā€™m off to build myself some virtual furniture. Thanks for creating this tutorial!

1 Like

Thank you for updating this tutorial for SteamVR 2.0! I really appreciate it :slight_smile:

1 Like

@blackdragonbe Do you have any feedback about this? Thank you - much appreciated! :]

Thanks for pointing that out Ben!
Iā€™ll take another look at the tutorial to see if I can fix those issues.

Cheers!
Eric

Hello,
Great tutorial! I have a question though. When I try to bind the controlls the localhost page wonā€™t load. Keeps saying that localhost cannot be reached. Any ideas on how to fix this issue?

Thanks!

@blackdragonbe Can you please help with this when you get a chance? Thank you - much appreciated! :]

iā€™m at Binding Action and i have this issue, i must have missed something, or maybe an update broke the tutorial flowā€¦

image

Edit: it might be because of a missing Actions.json, ill update my message if adding it manually fixes the issue (once i find where it needs to go)

Edit 2: nvm the json files are at the right place with the right action in themā€¦

Edit 3: i had to change the skeleton from skeleton to pose for it to work, is it normal or it will break something on the long run?