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

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

Discussion in 'VR' started by JakubVse, Aug 22, 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.