Fixed Teleporting with the Vive in Unity

Fixed Teleporting with the Vive in Unity


Having successfully ported my Unity project to the HTC Vive I wanted to give my users locomotion, so they aren't stuck in one 10 ft by 10 ft square. The SteamVR Unity Plugin comes with a script called 'Steam VR_Teleporter' and that requires a script called 'Steam VR_Tracked Controller', both of which have to be assigned to each controller (or just the one you want people to teleport with.) Sounds simple enough.

It wasn't.

Unfortunately there is an error with the teleporter script that basically makes it unusable without modification, and there are really no example scenes that show the proper usage.

After two long hours, I stumbled across this post on the Steam VR Developer Forums: http://steamcommunity.com/app/358720/discussions/0/487876568222540886/

 

Basically, to get teleportation to work you have to create 1 line of code right after line 43 of the Steam VR_Teleporter Script:

controllerIndex = (uint)this.GetComponent<SteamVR_TrackedObject>().index;

 

For some reason the default teleporter script doesn't correctly detect the index of the controller, and this line of code makes sure that it properly reads it to sense the necessary button presses.

 

On top of that, make sure the Controller index field in the Steam VR_Tracked Controller is set to 1 for the left controller, and 4 for the which, from what I understand, references the controllers, not the HMD or the base stations.

From there, you just have to set in the Steam VR_Tracked Controller settings which buttons you want to create a 'button pressed' event and I found that the 'Teleport on Click" and 'Teleport Type Use Zero Y' options for the Steam VR_Teleporter work best, but this is something I still have to experiment with!

Hopefully this helps with anyone who experienced this issue!