Search Unity

How can I rotate the VR Camera with the controller as well as headtracking

Discussion in 'AR/VR (XR) Discussion' started by RSH1, Apr 2, 2016.

  1. RSH1

    RSH1

    Joined:
    Jul 9, 2012
    Posts:
    256
    The standard camera in VR mode currently tracks with Oculus head movement, which is fine, but I'd like to also be able to rotate it using an Input axis on the controller (so the user doesn't have to physically spin 180 to look behind them if they don't want to), like in the Oculus Tuscany demo. How can I achieve this?
     
  2. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    I'd try having the controller rotate the camera parent's game object.
     
  3. RSH1

    RSH1

    Joined:
    Jul 9, 2012
    Posts:
    256
    This seems to work once I used UnityEngine.VR.InputTracking.GetLocalRotation(UnityEngine.VR.VRNode.CenterEye).eulerAngles to get the camera's orientation instead of the camera's forward vector. Thanks.
     
    Last edited: Apr 3, 2016
  4. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    Whatever works. :) Depends what you're doing probably, but I prefer in the case of a controller in a sit down game to have the mouse control the parent. Then it's like your mouse/controller is controlling your body while you're still free to move your head. Then you can walk in one direction while you look wherever you want, but can still turn the way gamers are used to with the mouse.
     
  5. jaridgoodman

    jaridgoodman

    Joined:
    Jul 18, 2017
    Posts:
    1
    I'm trying to get my camera to rotate on a trigger. Rotating the parent object does not work for me.

    Can you explain how I would use...

    UnityEngine.VR.InputTracking.GetLocalRotation(UnityEngine.VR.VRNode.CenterEye).eulerAngles

    ...to rotate the camera?