r/oculusdev • • Aug 31 '14

Capturing raw head position in Unity

Hey guys! I'm getting started with Unity and the DK2, and I'm trying to figure out how to get the raw position of the camera from the OVRCameraController prefab. I'd like to hang the body from it on a spring (as a kind of pseudo inverse-kinematics), but simply hanging it from one of the eye cameras causes problems during head rotation. What I'd like is just to be able to script an empty game object to stick to the position of the head (as returned by the camera) and then hang the body off it. Anybody know of a way to do that?

7 Upvotes

5 comments sorted by

View all comments

2

u/BullockHouse Sep 01 '14

UPDATE:

So, I eventually solved this. The code below appears to work:

public Vector3 headposition;

public Quaternion orientation;

OVRDevice.GetCameraPositionOrientation(ref headposition, ref orientation);

This will date the headposition and orientation variables with the correct values.