Unity VR teleport to object

Hi!

I am stuck on this thing with teleportation in Unity VR.

I want to make the player able to be moving ONLY using Teleport, and ONLY when he aims the pointer at the specific object and presses the trigger on the HTC Vive controller. Only after the player collects one object, the next object is spawned at the next spawn point.

Now I have a visible pointer coming out of the controller, and I have a script checking whether the player is aiming at the object or not.

I think I know what I have to do: get the position of the object the player is aiming at, pass this position to the current player’s position, and translate the current player’s position. But, still being a noob when it comes to scripting, I got confused with how exactly do I put this in C# now :stuck_out_tongue: Should I do this in the PlayerController script, or in the VRController script?

Since you are using VIVE, why don’t you download the free SteamVR and/or ViveInput Utility that provide you with prefabs for that? Analyse the scripts, and see how they do it. Valve’s code (was) somewhat ungainly, but it’s a nice exercise, and you’ll gain a lot insight. Then there’s also Unity’s own (now legacy) VR samples asset (free) that shows you how to do VR UI in general and has lots of interesting scripts to dissect.

From your description I am pretty sure that your problem can be solved by downloading this asset from the Unity Asset Store: VR Builder - Open source toolkit for VR creation | Visual Scripting | Unity Asset Store It is a FREE asset and makes teleporting super easy.

There is also a tutorial that explains how to teleport using this asset:

I hope this helps. Good luck!