Skip to main content
New Participant
May 3, 2017

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?
This topic has been closed for replies.

1 reply

741604688Author
New Participant
May 3, 2017
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?