Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[SOLVED] Disable head tracking of a specific camera and position it somewhere?

Discussion in 'AR/VR (XR) Discussion' started by CloudyVR, Jul 7, 2017.

  1. CloudyVR

    CloudyVR

    Joined:
    Mar 26, 2017
    Posts:
    714
    I am trying to make a hud for my vr player. But my trouble is that I can not figure out how to position a camera in my scene. It appears that SteamVR or OVR is forcing all cameras (one's that do not have RenderTextures or Target_Eye == None) to track the HMD. So in order to keep the hud objects in the view I must parent all of them to the camera which results is very noticeable jerky motion (especially when turning quickly).

    I am using a camera with a higher depth to render the objects in the vr hud, then I overlay that on the main camera:
    What I would like is to have a stationary camera and nothing parented to it.

    Is this possible to do when using OVR / SteamVR?

    I have tried many things, and searched Google extensively. I realize this is not an easy thing to acomplish (though maybe it should be).

    Things I have tried:
    • Set camera's position/rotation to all zeros in Update() -> camera still tracking.
    • Set camera's position/rotation to all zeros in LateUpdate() -> camera still tracking.
    • Removed SteamVR_Camera.cs and SteamVR_Tracked_Object.cs (repeated above) -> camera still tracking.
    • Spent 3-4 hours modifying/debugging SteamVR and OVR scripts -> cameras never stopped tracking.
    I'm at my wit's end and would so very much appreciate if someone could be kind enough as to help me understand why these cameras are being so stubborn? I saw some mentioning of anchors when I was reading through the SDK but I am not familiar with their usage. Could anchors be the culprit? If so can an anchor be superseded/disabled?

    [UPDATE]

    According to this link there is a hacky way to lock the position of a camera by setting it's parent's scale to (0,0,0). This works fine for translation.

    Then I tried using this script:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using UnityEngine.VR;
    4.  
    5. public class NegateTracking : MonoBehaviour
    6. {
    7.     void Update()
    8.     {
    9.         //CameraParent.transform.position = -InputTracking.GetLocalPosition(VRNode.CenterEye);
    10.         transform.rotation = Quaternion.Inverse(InputTracking.GetLocalRotation(VRNode.CenterEye));
    11.     }
    12. }
    13.  
    Now the camera tries very hard to stay in one spot but it's still not enough and there is a lot of jerky motion when turning head.

    I normally don't rant but Unity totally missed the point by denying it's developers control of simple cameras. I am not impressed.
     
    Last edited: Jul 8, 2017
  2. CloudyVR

    CloudyVR

    Joined:
    Mar 26, 2017
    Posts:
    714
    [SOLVED]

    So, just spent the whole night developing a functional workaround and put together a project that uses a little post processing magic to essentially "spoof" a stationary camera. My idea was to generate two renderTextures from a custom stereo camera setup consisting of two separate cameras that are not being tracked (which allows control of position, rotation, convergence plane. fov and so on). I then pass those camera's (left and right) renderTextures to the left and right eyes of one of the "tracked" cameras within the OnRenderImage() function. It worked better than I expected :), So I decided to put everything up on GitHub and write a short tutorial for anyone else needing to do this.

    Stationary Stereo Camera (Download From GitHub)




    Check out my other projects on my GitHub page.
     
    Last edited: Jul 8, 2017
    AdamBebko likes this.
  3. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    522
    What about FOV changes? Unity is setting the FOV of every camera in my scene to match the headset, which is absolutely not what I want.
     
    Audacity_Child likes this.
  4. NewMagic-Studio

    NewMagic-Studio

    Joined:
    Feb 25, 2015
    Posts:
    454
    Doesnt work with steamvr