- Home /
Reverse head tracker output around y axis
Hi, I am using Unity 5.3 and the oculus DK2 to prepare an experiment in psychology (so, as you can guess, I am not a developper). I would like to display a Unity scene flipped upside-down (not rotated) in the oculus. Following somes responses on Unity Answer, I attached the following code to the camera and it works well.
public class Mirrorcam : MonoBehaviour {
Camera MyCam;
void OnPreCull () {
MyCam = GetComponent<Camera>();
MyCam.projectionMatrix = MyCam.projectionMatrix * Matrix4x4.Scale(new Vector3(1,-1,1));
MyCam.SetStereoProjectionMatrices(MyCam.projectionMatrix, MyCam.projectionMatrix);
}
void OnPreRender () {
GL.invertCulling = true;
}
}
Now the scene is upside down but obviously we look on the left of the scene when turning the head on the right and vice versa. So I need to reverse the output of the oculus head tracker around the y axis. Again following some advices, I created an empty object as a parent for the camera and attached the following code to the object :
public class MirrorTracking : MonoBehaviour {
void Update ()
{
Quaternion angles = InputTracking.GetLocalRotation(VRNode.CenterEye);
transform.rotation = Quaternion.Euler(-2*angles.eulerAngles.x,angles.eulerAngles.y,-2*angles.eulerAngles.z);
}
}
It works relatively well (it is a bit unstable) as long as head movements are not too large. But when looking too far up and down, the camera starts spinning around. As I plan to have my participants in a supine position, it won't work... From what I read on the unity forum, I guess its because I am treating the element of a quaternion as euler angles but I don't know the math to do better. Is there another way to reverse head tracking data on one axis? Thank you for your help.
Your answer
![](https://koobas.hobune.stream/wayback/20220613011913im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Oculus Rift Track where the left palm goes 1 Answer
Disable Oculus tracking 1 Answer