cancel
Showing results for 
Search instead for 
Did you mean: 

How to add colliders to OVRGrabbable at runtime?

Anonymous
Not applicable
I generate objects at runtime that need to be grabbable. In the editor this is easy: drag the collider over the Grab Points field of OVRGrabbable and you're done. But how do I do this in script?

Actually I have this working already but only if my grabbable object has a **single** collider, not a compound collider. If anyone wants that, just add this code snippet to the OVRGrabbable script:

        virtual public void CustomGrabCollider(Collider collider)
        {
            m_grabPoints = new Collider[1] { collider };
        }

And then you call that wherever you generate your object and send the object's collider as argument. It's worked well for me, but now I need to do it with compound colliders.

In the editor it is again much easier. Even with compound colliders, I just drag my child object with all of the colliders attached over the Grab Points field (once the game is running and the object generated), and grab points becomes volume "1" with what looks like a single collider ![alt text][1]
and it works perfectly, and I can grab the object at any point on its compound collider. Obviously now I need this to happen automatically in script and to not be reliant on me adding it from the editor at runtime. Can't figure it out though. This is the best I have so far (This is added into OVRGrabbable):

        virtual public void CustomGrabColliders(Collider[] colliders)
        {
            m_grabPoints = colliders;
        }

But it doesn't work. m_grabPoints shows a volume of 0 in the editor when I use this method.
qm9rxy1qrkt9.png
So, how does the editor add the colliders to m_grabPoints if you just drag an object with colliders onto the protected field? Does anyone know how to make compound colliders work with OVRGrabbable at runtime?
0 REPLIES 0