Sockets on Grabbable objects in XRI 2.5.2

I’m trying to build a multi-tool in XR with attachments using the XR Socket Interactable components - something like a drill with a drill bit you want to attach to the end. So both objects are grabbable and have RigidBody components, one is a Socket and the other is a regular object with the appropriate key on it (if using the Lock Socket Interactor).

My problem is that I can attach the item into the socket, but when the player releases (drops) the main object, it flies off with some weird physics interaction. This GIF illustrates (this GIF anim is from the Editor but same happens if player slots in object then drops parent, in this case the grey “O”).


So I guess two questions:

  1. Is this even a good idea for a tool & attachment type of interaction? It would be the same for a gun and magazine I guess.
  2. How to prevent the crazy behaviour from these two rigidbody objects?

Thanks in advance!

Replying to my own post here, because I got help elsewhere. The fix in this case was to hook into the events on the sockets and apply Physics.IgnoreCollision between each of the colliders once an item had been inserted into a socket.

Here’s a cut-down version of the basic code, which mostly sits on the socket and is called when the socket is activated (called selectEntered):

This goes on your socket object and registers for events:

private void Awake()
    _socket = GetComponent<XRLockSocketInteractor>();

Then in your OnSelectEntered and OnSelectExited methods you call the next method as needed, and pass in the GameObject of the item which was inserted into the socket:

private void OnSelectEntered(SelectEnterEventArgs arg0)
    var other = arg0.interactableObject.transform.gameObject;
   SocketCollisionsIgnored(other, false)

Finally this goes on either the socket or the parent of the socket, as needed:

private void SocketCollisionsIgnored(GameObject other, bool flag)
    var myColliders = GetComponentsInChildren<Collider>(true);
    var theirColliders = other.GetComponentsInChildren<Collider>(true);
    // overkill - all (A,B) pairs will be duplicated (B,A) - optimise?
    foreach (var cA in myColliders)
        foreach (var cB in theirColliders)
            Physics.IgnoreCollision(cA, cB, flag);

End result is a grabbable socketed item which doesn’t go bonkers.