r/oculusdev • u/BullockHouse • 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
1
u/mptp Aug 31 '14
Just have a script that has something like
declared in the class, and
in Start(). Then in Update() you have something like
Then whenever you want you can just call newScript.cameraPos to get the camera position.
edit: assuming you're using C#. If you're using Javascript you're on your own.