Search Unity

Resolved Oculus Rift Track which direction the palm is facing in world space

Discussion in 'VR' started by bigvalthoss, Feb 25, 2021.

  1. bigvalthoss

    bigvalthoss

    Joined:
    May 26, 2020
    Posts:
    23
    I am trying to track which direction the palm of the controller is facing in world space, but I'm having trouble. Here is the code I am currently using:

    Code (CSharp):
    1. Vector3 wSpaceDir = OVRTrackingSpace.transform.TransformDirection(LeftHandAnchor.transform.right);
    2. Debug.Log("LHDir in world space from hand: " + wSpaceDir);
    The problem is that when you turn around, the tracking stays in reference to me. Meaning it will always say (1.0,0,0) if I have my hand straight in front of me but turn around in any direction. Any help greatly appreciated :).

    Thanks!
     
  2. bigvalthoss

    bigvalthoss

    Joined:
    May 26, 2020
    Posts:
    23
    Finally Figured it out.. Here is the code:
    Code (CSharp):
    1. Quaternion tempQua = OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTouch);
    2. Vector3 localPalmDir = tempQua * Vector3.right;
    3. Vector3 wSpaceDir = OVRTrackingSpace.transform.TransformDirection(localPalmDir);