Skip to main content
Participant
June 17, 2016

Sensor position

Hi, is there a way to find out where the sensor is located in C#?  I want to determine if the sensor is located on the left or right of the player. I have a brief moment where I want the player to turn around and I would rather have them do it toward the sensor as opposed to "opposite" of the sensor, for tracking purposes. Thank you.
    This topic has been closed for replies.

    5 replies

    Inspiring
    June 17, 2016
    Yep. Use the Oculus Utilities for Unity, add an OVRManager to your scene, and call OVRManager.tracker.GetPose(). Alternatively, use OVRCameraRig in your scene instead of a plain Camera and check the Transform OVRCameraRig.trackerAnchor.
    Participant
    June 18, 2016
    I've never used data from the OVRManager before and I do not know how to integrate this practically in a script. I looked online but couldn't find examples of what I'm looking for. Do you have an example of how tracker.GetPose would be used to tell if the sensor is on the left or right side of the player? Thanks
    Inspiring
    June 18, 2016
    OVRCameraRig.Update has an example use of OVRTracker.GetPose(). Basically, make a parent GameObject for your Camera, set the Camera's initial local position and rotation to 0, add a sibling GameObject for the sensor, and add a script to that GameObject that sets transform.localPosition and localRotation to the position and orientation of the OVRPose returned by OVRTracker.GetPose() each frame.
    Participant
    June 18, 2016
    ok. thanks,. it's a bit over my head but I'll take a look at OVRCameraRig.Update   I wish there was a C# full demo script of that somewhere, Not a whole lot of recent examples online. A lot of old ones.
    Inspiring
    June 18, 2016
    The simplest solution is probably to disable your existing Camera and use the OVRCameraRig prefab instead. That includes an anchor for the sensor that you can use without needing any code.