Search Unity

I need to set X rotation of object same as X rotation of VR controller

Discussion in 'AR/VR (XR) Discussion' started by JakubVse, Aug 23, 2019.

  1. JakubVse

    JakubVse

    Joined:
    Nov 12, 2018
    Posts:
    2
    I've got a object which has the x rotation same as controller of vr.

    Code (CSharp):
    1. transform.rotation = Quaternion.Euler(controller.transform.rotation.eulerAngles.x, 0, 0);
    But I need to rotate it 90 degrees that the object will be vertically not horizontally.

    Code (CSharp):
    1. transform.rotation = Quaternion.Euler(controller.transform.rotation.eulerAngles.x + 90, 0, 0);
    But this doesn't work properly, because you can rotate the object in only one direction.

    If you rotate controller right -> object rotate right & if you rotate controller left -> object rotate right.
    If you want to rotate object left you have to rotate controller upside down.

    I also tried set the object as child of controller but on play the object disappear.
     
  2. StayTalm_Unity

    StayTalm_Unity

    Unity Technologies

    Joined:
    May 3, 2017
    Posts:
    182
    I'm curious to see your code while parenting.
    Having a rotated object as the child of the tracked object should be the solution, and it should not disappear.