Oculus 0.4.3 Unity Camera Orientation Changes

Well I was brave and figured I’d grab the latest Oculus 0.4.3 runtime + Unity integration and see if it breaks anything too badly. For me, the biggest issue was that they deprecated the OVRCameraController and two methods that it had: OVRCameraController.SetOrientationOffset(Quat q) and OVRCameraController.GetOrientationOffset(Quat q). I used the GetOrientationOffset to interpret user gestures like nods and shakes (more on that later). This one was pretty straightforward to figure out. I started digging around in the new codebase, which now uses a class called OVRCameraRig instead of the old OVRCameraController. Interestingly though, this didn’t have what I was looking for.

Instead, the best replacement I found for getting a single Quaternion of the user’s head orientation was by doing this:

Quaternion quat = Quaternion.identity;
OVRPose ovp = OVRManager.display.GetHeadPose();
quat = ovp.orientation;

OVRManager has some static members, one of them being a handle to OVRDisplay. OVRDisplay has a handy GetHeadPose that returns a wrapper OVRPose. Inside there, you can get position and orientation information.

Ok so that’s how to get the orientation now. But what about setting it? You used to be able to set the offset, which would let you take some control over the camera during gameplay. Obviously you don’t want to go crazy with this and make players sick, but I find that a little bit of camera shake in certain situations can help sell impact.

Well the Unity integration folks at Oculus have made things much simpler. Now you can manipulate the OVRCameraRig gameobject and it just works. Previously I went through some gyrations to set that offset rotation, but now a good camera shake is as easy as

iTween.PunchRotation(_ovrCameraRig.gameObject, headPunchVector, .5f);

And if you want to get fancy you can find a proper vector before doing so.

Do you do camera shake differently? Am I doing stupid stuff? Drop me a comment!

 

One thought on “Oculus 0.4.3 Unity Camera Orientation Changes

  1. Do you want to copy posts from other sources rewrite them in seconds and post on your website or use for
    contextual backlinks? You can save a lot of writing
    work, just type in google:
    rheumale’s rewriter

Leave a Reply to Leta Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>