I just started using Unity 6 weeks ago. Can someone tell me the start to finish method for putting the Oculus go pointer/cursor into a scene, and having the controller prefab tracked (so if the user is waving it or rotating it shows in the scene play mode)? Doesn't have to have the line renderer. Please help, the tutorials on YouTube aren't that helpful
Sure, it's pretty easy. Create the following script: Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; public class OculusVRTracking : MonoBehaviour { public Transform controller; public static bool leftHanded { get; private set; } System.IO.StreamWriter recording; void Awake() { #if UNITY_EDITOR leftHanded = false; // (whichever you want to test here) #else leftHanded = OVRInput.GetControllerPositionTracked(OVRInput.Controller.LTouch); #endif } void Update() { OVRInput.Controller c = leftHanded ? OVRInput.Controller.LTouch : OVRInput.Controller.RTouch; if (OVRInput.GetControllerPositionTracked(c)) { controller.localRotation = OVRInput.GetLocalControllerRotation(c); controller.localPosition = OVRInput.GetLocalControllerPosition(c); } } } Attach this script to some object in the scene. Now create whatever you want to represent the controller visually (I typically start in a new project with just a scaled cube, with maybe another cube sticking out of one face like a wand). Drag that into the controller slot on object where you attached the above script. That's it. Build & run, and you should see your object moving around as you move the physical controller. Note that we're only changing the local position and rotation with this script. And as it happens, the XR system only changes the local rotation of the camera. Probably you'll want to put the visual controller object, and the main camera, under some other game object that represents the player. Then you can move/rotate this player object, and both the camera and the controller will go along with it.
Thanks, JoeStrout, for providing this solution! Out of curiosity: Is there a particular reason, why you're reinitializing the c variable every tick in Update(). Wouldn't it be sufficient to do this once in Awake()?
Yes, the reason is, players can switch the handedness of their controller while your app is running. And if you fail to detect that and deal with it properly, then you fail the Technical Review, and Beatron 2000 doesn't come out till a week after Thanksgiving!
Ok, I see! Thanks. So I guess it's not THAT relevant for a mere private project when I am deploying only to my own device in developer mode?
Is there any way to see this in the editor? More detail: I added the OVRCameraRig prefab - so holding `ctrl` and moving the mouse lets me control the camera I also created an object and added the above script to it. I would now like to be able to control it in the editor so that I can test actions like "moving the wand around and firing projectiles" Thanks!