Adding OVRGrabbable during runtime

Viewed 74

I am working on an environment that allows uploading a 3d model which should be interactable at the end. I do have the structure and Instantiate the model from a prefab. The problem is, that I need it to be grabbable at the end. Since I'm using Oculus I just tried to add a Rigidbody and the OVRGrabble Script. The script will be added but is deactivated.

Once I use this line to activate the script:

gameObject.GetComponent<OVRGrabbable>().enabled = true;

I get the following error:

OVRGrabbable.Awake () (at Assets/Plugins/Oculus/VR/Scripts/Util/OVRGrabbable.cs:133)
UnityEngine.GameObject:AddComponent()
ObjectManager:loadModel() (at Assets/Scripts/ObjectManager.cs:76)
ObjectManager:initiateModel() (at Assets/Scripts/ObjectManager.cs:47)
Colour:Start() (at Assets/Scripts/Colour.cs:134)

I also tried waiting for a frame since I thought it might be an issue to add the components and directly activate them but it still won't work. Any suggestions? Using Unity 2019.4.19f1

0 Answers
Related