Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
bcoyle's avatar
bcoyle
Adventurer
9 years ago
Solved

Unity and Rift | player position in relation to camera

Hi,

I'm planning to build a 1:1 model of the space I have the Rift setup in, which includes a table. I also want the headset to match the physical space positionally. Is there a way to adjust the player controller so that it lets the headset load in the proper space in relation to where the camera is setup? I think I'm looking for something more like a 'player controller' for the camera. So I can position the camera in the Unity scene to match the real one - and have the headset/player created in relation to that?
  • Try something like this:

    using UnityEngine;
    using System.Collections;

    public class AlignToTracker: MonoBehaviour
    {
    public OVRPose trackerPose = OVRPose.identity;

    void Awake()
    {
    OVRCameraRig rig = GameObject.FindObjectOfType<OVRCameraRig>();

    if (rig != null)
    rig.UpdatedAnchors += OnUpdatedAnchors;
    }

    void OnUpdatedAnchors(OVRCameraRig rig)
    {
    if (!enabled)
    return;

    OVRPose pose = rig.trackerAnchor.ToOVRPose(true).Inverse();
    pose = trackerPose * pose;
    rig.trackingSpace.FromOVRPose(pose, true);
    }
    }

12 Replies

Replies have been turned off for this discussion