Search Unity

Question Add and remove OVRGrabber Script

Discussion in 'VR' started by SaungStudio, Jan 22, 2021.

  1. SaungStudio

    SaungStudio

    Joined:
    Sep 21, 2020
    Posts:
    10
    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<OVRGrabber>());
    Destroy(righthand.GetComponent<OVRGrabber>());

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

    lefthand.AddComponent<OVRGrabber>();
    righthand.AddComponent<OVRGrabber>();
     
  2. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,822