Unity Oculus VR lock rotation of a grabbed object
For an Oculus Quest game i'm working on, I need to be able to grab an object and not rotate it in any way. I should be able to move it in x y and z though. I'm doing this in a climbing game and the object is quite big. My player is locked on (0,0,0) and you climb by grabbing the terrain and moving it, giving the illusion that you are climbing
I am using Unity's Oculus integration asset and I have the OVR Grabbable script on the object I want to be able to grab.
I've tried using a rigidbody and locking the rotation like that, but that doesn't work. Once I grab it, I can still rotate the object.
I've also tried adding a bit of code in the script, which would reset the objects rotation in the fixed update, but that caused my game to freak out big time, so that's not a good idea either.
I am not using VRTK, because that does not work with the type of climbing I'm trying to achieve.
Do you have any ideas on how to lock this objects rotation while it's being grabbed? Please send them my way.
Answer by unity_wvdBsmlMTIpFOQ · Feb 06, 2020 at 10:27 AM
The only way I know about is to save initial rotation in script, and in the LateUpdate reset rotation to initial... Good luck
Example: Start(){ initialRot = transform.rotation; grab = GetComponent();} LateUpdate(){if(grab.isGrabbed) transform.rotation = initialRot;}
Your answer
Follow this Question
Related Questions
Oculus package removes itself and "Virtual Reality Supported" being disabled 0 Answers
Oculus Quest: Unable to grab grabbable object,Oculus Unity: Can't grab object with OVRHands 0 Answers
Oculus: Works fine in editor but not working in build 1 Answer
Oculus Integration & Smooth object rotation by grab 0 Answers