• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by MikePage_Artrix · Mar 23, 2016 at 12:32 PM · camerarotationoculus

Override Oculus Orientation 5.3

So with the new VR support the main camera's transform is being overridden with the Oculus transform.

I kinda get this in a general use case but I need to able to override this behaviour.

Specifically I want to override the orientation so that the real world Oculus orientation maps to a greater in-game orientation, particularly on the local y-axis i.e. when I turn my head 90 degrees in the real world, I want to be facing 180 degrees in game.

This is something I have done before in VR on other engines and is a critical part of many locomotion systems you'll see being used.

So how do I go about this, I understand I could always child the camera to a parent and then rotate the parent using the Oculus orientation as a base but this is messy and a bit of a quaternion nightmare.

Comment

People who like this

0 Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image meat5000 ♦ · Mar 23, 2016 at 10:27 AM 0
Share

What have you tried?

avatar image MikePage_Artrix meat5000 ♦ · Mar 23, 2016 at 07:55 PM 0
Share

I've just simply adjusting the camera transform in many positions of the game update, Update(), LateUpdate() etc... but in every case the new transform I set is simply stamped over.

Currently I have a reasonable solution whereby the camera is parented to another transform, in that transforms' update I take the orientation of the oculus, extract the yaw component. I then create a new create a new quaternion with the desired increase in yaw around the transforms up axis and set this to be the rotation.

This works but does break on occasion and also taking the transform of a child to populate a parent is just awful.

I simply want to be able to intercept the oculus orientation and modify it before it gets applied to the camera.

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by zachduer · Oct 24, 2016 at 10:16 PM

Took a few minutes to figure out, but in case anyone in posterity is curious, here's how:

The OVRPlugin class has boolean properties for both position and rotation. Setting these properties in turn calls methods in the oculus plugin itself to enable and disable the position and orientation tracking. Setting rotation in OVRPlugin to false (or, more tediously, getting a reference to the oculus plugin and calling its method: ovrp_SetTrackingOrientationEnabled(false)) will disable rotation transformations from being applied to the camera in Unity.

You can find this at lines 425-435 of the OVRPlugin.cs script that comes in that unitypackage.

The above is true for version 1.8 of Oculus Utilities for Unity 5.

(In retrospect, I realize I'm not 100% answering the question of the OP, as I'm not intercepting the rotation values, but rather disabling them entirely (which is what I needed for my own purpose)).

Comment
roetka

People who like this

1 Show 10 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image roetka · Mar 17, 2017 at 01:33 PM 0
Share

I know, this thread is a bit older, but I have nearly the same problem right now on my own.

For me, this is not working. I tried it with the Oculus Utilities 1.8 and Unity 5. Can you provide a project with which I can test it out?

Thanks in advance.

avatar image zachduer · Mar 17, 2017 at 02:02 PM 0
Share

Roetka, what exactly are you trying to accomplish?

avatar image roetka zachduer · Mar 17, 2017 at 02:17 PM 0
Share

I need to deactivate the whole tracking of the HMD. In my case I need to deactivate the tracking because I want to use another MoCap System.

avatar image zachduer roetka · Mar 17, 2017 at 02:39 PM 0
Share

Great! I'm doing the exact same thing.

Here is a simplified project that disables both position and rotation from the Oculus. https://drive.google.com/file/d/0B38bbn4KOP60MFliVmhBUkFjbnM/view?usp=sharing

Additionally, though, I will note that I have had best success when using the rotation from the Oculus and the position from the mocap system. The latency from the mocap system is always going to be higher than that of the IMU built into the headset. In this case, you don't need to mess with any scripts at all. In OVRManager, just turn of UsePositionTracking, and then cover the sensor with a piece of tape to double-down and make sure it doesn't send any position data. Then, send your mocap position data to the TrackingSpace transform. The last thing you'll need to do is align the axes of the mocap system with the axes of the IMU rotation. To do that, make a simple script that that calls VR.InputTracking.Recenter(); And maybe have it do that when you press spacebar, or some other hotkey. Then, when you start up, aim the headset toward Z+ in your mocap space and activate that Recenter call, and you'll be set to go. Note that the gyros in the IMU do drift, so you may need to do this every so often during a session.

I've made two scenes in the example project... one to disable all OVR tracking, and one to use rotation from OVR and position from mocap system. It's slightly abstracted because I didn't want to include my own mocap code.

Hope that helps!

Show more comments
avatar image Mastermonk · Mar 17, 2017 at 10:05 PM 0
Share

@zachduer, thanks for sharing the project. I tried to run it and i would like to do the same as you mentioned. I would like to use the position of the Mocap system (Xsens) and use the orientation of the Oculus. Now I tried the small scene you added "UseOVRRotation". The only thing i'm bumping into is actually attaching it to my Mocap system. Well, attaching works by just draging it onto the neck for example, but i can't get to at that location once booting the game. Could you give a dumbed down explanation on how to get that to work please? Do keep in mind that i'm not much of a programmer, so much of this is pretty new to me.

avatar image zachduer Mastermonk · Mar 20, 2017 at 01:21 PM 0
Share

Hi Mastermonk!

I've never had a chance to use the Xsens suits, so it's possible my reply may not be suitable.

I don't quite understand what you mean that you're not able to "get at that location once booting the game." However, it sounds like what you're trying to do is apply the OVR camera to the head of an avatar that's part of the mocap controlled avatar. This is different than what I'm doing. I'm not using a full avatar; I have a virtual camera being positioned based on the location of a single rigid body. It's unclear to me exactly what you're saying, but I'll take a guess: If you're attaching your camera to the head of your avatar that's part of a skeleton driven by the mocap system, it might be tricky to turn off the mocap rotation of that part of the skeleton and instead use the rotation of the IMU. As a test, I would recommend pulling the camera out of that hierarchy and instead first just try setting its position and rotation to whatever the coordinates are from the mocap, separated from the rest of the skeleton. If that works, go from there, trying to disable the rotation from mocap and use the IMU of the Oculus.

Or, if I'm misunderstanding, please feel free to clarify.

avatar image Mastermonk zachduer · Mar 20, 2017 at 03:17 PM 0
Share

Thanks for the reply. What you are saying is indeed what i'm trying, although i'm not attaching the OVR to the head, but to the neck. I would like to use the orientation of the Oculus instead of the IMU's.

The problem i'm encountering is on how to attach your version to a bone? I'm not a programmer, so most if this is pretty new.

Can I just add a rigid body to the neck and attach the OVR to that?

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Set skateboard (gameobject) to rotate with OVR camera 1 Answer

Freeze Camera Rotation that is attached to the object in certain moments 0 Answers

layered 2d plane meshes ordering messes up when rotated 0 Answers

help with my orbit camera script 0 Answers

Cinemachine camera rotating with player 2D 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges