Which is the correct way to rotate the XRrig?
I am creating a Virtual Reality application using the XR Interaction Toolkit and I need to rotate the camera view when the player moves the controller thumb-stick, I have seen from this example project that this can be done using the script SnapTurnProvider.
This is great, but after the player rotates ( in my application) and he tries to throw objects they collide with something. I noticed that this happens only when the XRRig is rotated, what could be the possible problem? Which is the correct way to rotate the player with this kind of tool?
I am also using a different way to interact with object, using a script that extend XRInteractable but not the XRGrabInteractable script provided by the Toolkit
This is how I set the LocomotionSystem (similarly to to the EscapeRoom)
This is my XRrig structure:
Answer by salvolannister · Jul 29, 2020 at 10:17 AM
Basically I had the exact same issue reported here, then adjusting my script where I was releasing the object from the hand, considering what was said from Opp33 it solved my problem:
//Drop here, in the inspector, the "TrackingSpace" element of your XrRRig
public Transform trackingSpace;
//.........REST OF THE CODE.........//
void Drop()
{
Rigidbody objectRigidbody = grabbedObject.GetComponent<Rigidbody>();
//Just multiply controller velocity by the direction your body is facing!!!
objectRigidbody.velocity = trackingSpace.rotation * OVRInput.GetLocalControllerVelocity(controller);
objectRigidbody.angularVelocity = OVRInput.GetLocalControllerAngularVelocity(controller);
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613004255im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Minor issue with a VR head tracking script to control the camera? 1 Answer
Can we manually set a rotation and a position for the XR rig / VR Headset Oculus Rift ? 0 Answers
Control movement with head rotation in cardboard 0 Answers
VR Scene Rotation on Build 0 Answers
Rotating a sphere with VRTK_Pointer 0 Answers