Reputation: 33
I've got a object which has the x rotation same as controller of vr.
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.
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.
How can I solve?
Thanks in advance.
Upvotes: 1
Views: 235
Reputation: 4888
You could assign your rotation to be equal to the controller's right vector.
this.transform.rotation = Quaternion.LookRotation(controller.transform.right, Vector3.up);
Upvotes: 1