Search Unity

Bug Adding colliders to XRGrabInteractable during runtime doesn't work

Discussion in 'XR Interaction Toolkit and Input' started by edwon, Aug 21, 2022.

  1. edwon

    edwon

    Joined:
    Apr 24, 2011
    Posts:
    266
    If I add colliders to XRGrabInteractable in code (but not on awake) it appears to not register the colliders. They are not detected at all.

    I have a need in my game to change which colliders are registered to an XRGrabInteractable at times. I was able to get it working by having all the potential colliders I might swap too in the colliders list set in the inspector before startup. If I do that, and then swap them in code (only to ones that were there on startup) then it works, but this sure seems like a bug. I should be able to just add any collider at any time and have it work right?
     
  2. VRDave_Unity

    VRDave_Unity

    Unity Technologies

    Joined:
    Nov 19, 2021
    Posts:
    275
    Hey @edwon,

    We have this task tracked in our backlog. Currently the easiest way to update the collider registration is to disable and re-enable the
    XRGrabInteractable
    , which will trigger the registration process anew.
     
  3. edwon

    edwon

    Joined:
    Apr 24, 2011
    Posts:
    266
    ok will try diable and reenable of the XRGrabInteractable after changing colliders
     
  4. Kek_Chpeck

    Kek_Chpeck

    Joined:
    Feb 9, 2019
    Posts:
    16
    XR Interaction Toolkit 2.4.3. Still reproduced.
     
  5. detzt

    detzt

    Joined:
    Oct 6, 2018
    Posts:
    21
    Still an issue in XR Interaction Toolkit 3.0.0-pre.1.

    Thank you for the workaround @VRDave_Unity disabling and re-enabling partially works, but it drops the XRGrabInteractable if it is grabbed (selected) at that time.

    The system does not have to keep track of the colliders automatically. Manually calling something like
    XRInteractionManager.UpdateColliders(XRInteractable interactable)
    or even more explicit
    XRInteractionManager.ColliderAdded(XRInteractable interactable, Collider collider)
    and
    XRInteractionManager.ColliderRemoved(XRInteractable interactable, Collider collider)
    would be totally fine for me.