Search Unity

How to get the facing direction of the custom hands in the quest

Discussion in 'VR' started by jeromegold, Apr 30, 2020.

  1. jeromegold

    jeromegold

    Joined:
    Apr 7, 2020
    Posts:
    47
    Hi,

    How can I get the forward direction of the custom hands (or any of the bones/joints)?
    I think Vector3 fwd = rightHand.transform.TransformDirection(Vector3.forward); just gets the direction of the x axis, not the forward location in 3d space.

    thx
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    That's incorrect. The expression you give above is the full 3D forward direction.
     
  3. jeromegold

    jeromegold

    Joined:
    Apr 7, 2020
    Posts:
    47
    Ok thanks. I'm trying to get a straight line from the custom right hand coming out forward using a line renderer. It works but the line is coming out at 90 degrees (i'm pretty sure its 90 degrees).

    Vector3 fwd = rightHand.transform.TransformDirection(Vector3.forward);
    lr.SetPosition(0, rightHand.transform.position);
    lr.SetPosition(1, fwd);

    There's no rotation on any of the prefabs from ovrplayercontroller, ovrcamera rig, etc. all the way down. x, y, z are 0.
    The start position of ovrplayercontroller is -1.5, 1.5, 2.5 but don't think that should be an issue.
     
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    On your line renderer, you're setting position 0 to a world position, but setting position 1 to a direction. That doesn't make any sense.

    If your line renderer is using local coordinates, then position 0 should be Vector3.zero. And if it's using world coordinates, then position 1 should be a world coordinate, not a direction vector.
     
  5. jeromegold

    jeromegold

    Joined:
    Apr 7, 2020
    Posts:
    47
    Awesome. Makes sense. Thx.