- Home /
VR Physics Hands Rotate In Opposite Direction
I tried to make a working vr physics hand and everything was successful, except for the fact that with how the controllers in unity's xr package is tracked there's a certain point in the rotation where the quaternion will flip from 0.6f to -0.6f causing the physical hand to rotate in the opposite direction to re-align itself. The code is completely fine as you'll see I'm just wondering how to circumvent this issue of the hand rotating in the wrong direction because of the sudden sign change and I've been banging my head at it for about a week or two now. Thanks for reading!
[SerializeField] private Transform controller; [SerializeField] private Rigidbody rigidBody; private void FixedUpdate() { rigidBody.velocity = (controller.position - transform.position) / Time.fixedDeltaTime; Quaternion rotationDifference = controller.rotation * Quaternion.Inverse(transform.rotation); rotationDifference.ToAngleAxis(out float angleInDegree, out Vector3 rotationAxis); Vector3 rotationDifferenceInDegree = angleInDegree * rotationAxis.normalized; rigidBody.angularVelocity = rotationDifferenceInDegree * Mathf.Deg2Rad / Time.fixedDeltaTime; }
Answer by cameron_a2 · Apr 25 at 12:03 AM
If you got this from the Valem tutorial, I was also looking for an answer for a while, however I seemed to come up with one that worked fine for me. What worked for me was dragging the whole Left Hand Physics Presence object under the LeftHand Controller object (same place where the Left Hand Presence should be). Do the same for the right hand and that might work. If you didn't get this from the Valem tutorial maybe you can try to apply the same concept.
Whether or not this is the best way to do this I'm not sure, but its been working fine for me so far :)
Your answer