Forum Discussion

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

I have a question,How do I lock HMD in Unity?

I don't want to make the picture changes,HMD rotate and move, HMD rotate and move, always show the current HMD current image.The HMD show only the pictures,Not rotate and move.What's the solution?

1 Reply

Replies have been turned off for this discussion
  • using UnityEngine;
    using System.Collections;
    public class FakeTracking : MonoBehaviour {

        public OVRPose centerEyePose = OVRPose.identity;
        public OVRPose leftEyePose = OVRPose.identity;
        public OVRPose rightEyePose = OVRPose.identity;
        public OVRPose leftHandPose = OVRPose.identity;
        public OVRPose rightHandPose = OVRPose.identity;
        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;
            //This doesn't work because VR camera poses are read-only.  
            //rig.centerEyeAnchor.FromOVRPose(OVRPose.identity);  
            //Instead, invert out the current pose and multiply in the desired pose.  
            OVRPose pose = rig.centerEyeAnchor.ToOVRPose(true).Inverse();
            pose = centerEyePose * pose;  rig.trackingSpace.FromOVRPose(pose, true);
            //OVRPose referenceFrame = pose.Inverse();  
            //The rest of the nodes are updated by OVRCameraRig, not Unity, so they're easy.  
            rig.leftEyeAnchor.FromOVRPose(leftEyePose);
            rig.rightEyeAnchor.FromOVRPose(rightEyePose);
            rig.leftHandAnchor.FromOVRPose(leftHandPose);
            rig.rightHandAnchor.FromOVRPose(rightHandPose);
            rig.trackerAnchor.FromOVRPose(trackerPose);
        }


    Using FakeTracking script, screen will be shaking, The problem of jitter have a solution?