New to the forums? Click here to read the "How To" Guide.

Developer? Click here to go to the Developer Forums.

HMD behaves differently in Editor / Standalone

oculus_dzneoculus_dzne Posts: 12
NerveGear
Hello everybody, 

my team and I are developing experiments for Neuropsychology, that make use of the Oculus Rift. In one of the experiments, the HMD is required to "stay still", meaning we have to disable tracking of movement, so that the image displayed stays the same, regardless of the users head movement. I know this is bad and not the intended behaviour, but it is how it is.

We achieved the "untracking" thanks to cybereality's  reply to our original question. After that, the requirements tightened up even more for a different paradigm, where only change in the y axis is allowed. We achieved this behaviour, however, the code we use only works in the editor, but not in a standalone build in Unity (5.4.0 - 5.4.2), tested on Rift and DK2 with and without sensor.


using UnityEngine;
using UnityEngine.VR;

public class HMDController : MonoBehaviour {

    private Camera cam =null;
    private bool blockRotation = true;
    private bool blockPitchRoll = false;

    void Start()
    {
         cam = this.GetComponentInChildren<Camera>();
         blockRotation = true;
         blockPitchRoll = false;
}

    void Update()
    {
        if (blockRotation)
        {
           this.transform.localRotation = Quaternion.Inverse(cam.transform.localRotation);
        }

        if (blockPitchRoll)
        {
                cam.transform.localRotation = new Quaternion(0, cam.transform.localRotation.y, 0, cam.transform.localRotation.w); //cant set w to 0 as it will inverse the direction of camera
        this.transform.localRotation = Quaternion.identity;
        }
    }

    public Quaternion GetHMDOrientationData()
    {
        Quaternion currentOrientation = InputTracking.GetLocalRotation(VRNode.Head);
        return currentOrientation;
    }

***omitted public setter for booleans blockRotatoin & blockPitchRoll ***

This script is attached to OVRCameraRig, the Script that calls the setter is attached to OVRPlayerController.
Does anyone have an idea what the problem could be or we should start looking?

With best regards
Sebastian
Sign In or Register to comment.