How to add child colliders to a parent XRGrabInteractable collider list?

I have a GameObject which is a Grab Interactable, one of the children of that object has a box collider that I would like to add to the colliders list. However, when this collider is added to the XRGrabInteractable collider list, you are still unable to grab using the area defined by that box collider.

The specific application is that the child can be shifted and rotated via user input, but I still want to be able to grab the parent element using the collider attached to the child.

As long as the collider is properly registered and follows the collision action matrix that should work. If you are modifying the colliders at runtime they might not be properly registered with the interactable component.

If you have post some images of your object setup I might be able to provide some more details or help in how to set it up.

Here is the object tree in question:

8390823--1107150--Collider1.PNG

The goal is to be able to grab and move FocusVR Standard Mount (1) using the box collider on Model.

The mount has two box colliders itself, and the third box collider for the grab interactable should come from it’s child, Model.

8390823--1107162--Collider5.PNG
8390823--1107159--Collider4.PNG

We have not been able to get this setup to work in order to grab the element my the model hitbox. Currently we have a workaround where a third box collider on the top level imitates the center and size of the child hitbox, but this fails to capture rotation.

8390823--1107153--Collider2.PNG
8390823--1107156--Collider3.PNG

Bumping this, still haven’t got an answer

I also stumbled upon this, so in case some else needs the solution: You simply have to unregister and reregister the interactable on the interaction manager like this:

        var coll = meshObj.AddComponent<SphereCollider>();
        var inter = GetComponent<XRGrabInteractable>();
        inter.colliders.Add(coll);
        inter.interactionManager.UnregisterInteractable(inter.GetComponent<IXRInteractable>());
        inter.interactionManager.RegisterInteractable(inter.GetComponent<IXRInteractable>());
3 Likes

@DonJorris - thanks for the answer. I spent hours trying to debug this.

Calling unregister/registering on interactable directly after adding the collider didn’t work for me, but spacing the calls out in a coroutine seemed to do the trick:

    ...
    inter.colliders.Add(coll);
    StartCoroutine(ReregisterInteractable());
}

private IEnumerator ReregisterInteractable()
{
    yield return new WaitForEndOfFrame();
    inter.interactionManager.UnregisterInteractable(inter as IXRInteractable);

    yield return new WaitForEndOfFrame();
    inter.interactionManager.RegisterInteractable(inter as IXRInteractable);

    yield return null;
}
1 Like

Oh Gosh, thank you so much, this drove me nuts!