Search Unity

XRGrabInteractable moved in Hierarchy when grabbed

Discussion in 'AR/VR (XR) Discussion' started by sterlingm, Mar 20, 2020.

  1. sterlingm

    sterlingm

    Joined:
    Jul 14, 2017
    Posts:
    15
    When I grab one of my XRGrabInteractable objects, that game object is moved from wherever it is in the Hierarchy to be at the parent level of the Hierarchy.

    Is this expected behavior?

    In the following image, you can see that the "left" game object is a few levels deep in the hierarchy. (sorry for so many other things showing in there. I put an arrow to point out the object.)


    The "left" game object has an XRGrabInteractable component on it. When I grab it with a direct interactor, it gets pulled from its current spot in the hierarchy put to be at depth level 0 in the hierarchy. You can see that in this image:



    I am basing my project on a tutorial shown here
    but the interactable game objects are not moved from their hierarchy position in the video. You can see them grab the object starting around 19 minutes in.

    If this is NOT expected behavior, then does anyone know what might be set up incorrectly to cause this?
     
  2. sterlingm

    sterlingm

    Joined:
    Jul 14, 2017
    Posts:
    15
    Line 389 of XRGrabInteractable is "transform.parent = null;" (in method onSelectEnter), so this must be intentional. However, if I comment this line out, then the interactable still tracks the controller.
     
  3. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    Why would you want them to stay in the hierarchy? That's going to cause a LOT of problems if their parent objects move while you're holding them.

    There's been some bugfixed around the code for this (if I remember correctly, until the latest version it put them somewhere else in the hierarchy, which caused problems in a few situiations), so it might be they're still iterating on it.
     
  4. sterlingm

    sterlingm

    Joined:
    Jul 14, 2017
    Posts:
    15
    Oh I didn't think about that. This behavior makes sense to prevent that problem.
     
  5. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    EDIT: no, I made an idiot mistake. Apparently I need glasses, can't look at a hierarchy and see what lines up where :).
     
    Last edited: Mar 28, 2020
  6. Riiich

    Riiich

    Joined:
    Sep 30, 2014
    Posts:
    19
    bittuz likes this.