- Home /
Question by
karelhladky · Jun 10, 2019 at 07:41 AM ·
vrmathalign
Align object to line between VR hands
Hello everyone!
I'm trying to solve following situation: I have a basket (box with hole on the top) and I want to align to line which is defined by two points (left and right VR controllers). I'm using this code:
Vector3 basketPosition = (Hand1.gameObject.transform.position + Hand2.gameObject.transform.position) / 2f;
Vector3 basketDirection = Hand2.gameObject.transform.position - Hand1.gameObject.transform.position;
Basket.transform.position = basketPosition;
Quaternion basketOrientation = Quaternion.LookRotation(basketDirection);
Basket.transform.rotation = basketOrientation;
And it works well. But when I move let's say the left controller to the right side behind the right controller, basket should be upside down. Any suggestions how to solve it?
Many thanks
Comment
Your answer

Follow this Question
Related Questions
VR: Controller rotation delta along other axis 2 Answers
Is this a valid projection matrix and why? 1 Answer
NewtonVR fix. Translating a point and rotation inline with changes from another gameobject. 0 Answers
How to scale/calculate GameObject Z distance to the real physical world... 0 Answers
Quick Math Help with Normalized numbers 2 Answers