Add and remove OVRGrabber script from source code

I am currently writing a project and checking the condition : the accident occurred when the object was dropped by hand controllers and touch the floor. After the accident, I want to make the hand controllers can’t grab object so I removed OVRGrabber script from LeftHandAnchor and RightHandAnchor but couldn’t add back the script from source code.

Here is my script,
GameObject lefthand = GameObject.Find(“LeftHandAnchor”);
GameObject righthand = GameObject.Find(“RightHandAnchor”);

Destroy(lefthand.GetComponent());
Destroy(righthand.GetComponent());

and then I added back the Script but isn’t working

lefthand.AddComponent();
righthand.AddComponent();

Not sure what an OVRGrabber might contain, but it might need linkages to other things (perhaps set up in the editor) to function. Just nuking it and adding a fresh one later may not work for that reason.

I recommend you ask around the AR/XR/VR group also in this forum to see if anyone is familiar with this API.

Thanks for your advice, and I made the object’s collider disabled when the accident occurred. For now it works with current solution, but I will look into it later, there must be a ‘ready to go’ solution.

1 Like