Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Multiple interactors selecting the same interactable with XR Interaction Toolkit

Discussion in 'XR Interaction Toolkit and Input' started by aboogoost, Mar 12, 2020.

  1. aboogoost

    aboogoost

    Joined:
    Nov 6, 2016
    Posts:
    10
    I've just started using the XR Interaction Toolkit and I'm trying to get my custom interactors to be able to select the same interactable simultaneously. Is this supported? The existence of
    requireSelectExclusive
    on
    XRBaseInteractable
    makes me think that it is but I haven't been able to achieve it.

    Here's my examples that I've created to try to figure it out:

    Code (CSharp):
    1. using UnityEngine.XR.Interaction.Toolkit;
    2.  
    3. public class TempInteractable : XRBaseInteractable
    4. {
    5. }
    Code (CSharp):
    1. using System.Collections.Generic;
    2. using UnityEngine;
    3. using UnityEngine.XR.Interaction.Toolkit;
    4.  
    5. public class TempInteractor : XRBaseInteractor
    6. {
    7.     public override bool requireSelectExclusive { get { return false; } }
    8.  
    9.     public override void GetValidTargets(List<XRBaseInteractable> validTargets)
    10.     {
    11.         validTargets.Clear();
    12.         validTargets.AddRange(FindObjectsOfType<TempInteractable>());
    13.     }
    14. }
    15.  
    I have two GameObjects with the
    TempInteractor
    and one with the
    TempInteractable
    . In the XR Interaction Debugger I can see that the interactors automatically select the interactable but only one can do it at a time.

    What am I doing wrong?
     
    Last edited: Mar 12, 2020
  2. aboogoost

    aboogoost

    Joined:
    Nov 6, 2016
    Posts:
    10
    The original version was incorrect but the new version (edited above) still doesn't work. I'm going to look into overriding other functions to see if there's some default functionality that I need to replace. I'll update if/when I figure something out.
     
  3. aboogoost

    aboogoost

    Joined:
    Nov 6, 2016
    Posts:
    10
    From what I can tell,
    requireSelectExclusive
    isn't considered by the Interaction Manager. It is queried but then it calls
    OnSelectExit
    on the currently selecting
    Interactor
    before calling
    OnSelect
    on the new
    Interactor
    .

    Also as a side note the documentation says the property is called
    isSelectExclusive
    but
    XRBaseInteractor
    doesn't have that property and instead has
    requireSelectExclusive
    . I'm going to move on for now and hope that someone tells me what I'm doing wrong or, if it's a bug, it gets fixed in a future version.
     
  4. aboogoost

    aboogoost

    Joined:
    Nov 6, 2016
    Posts:
    10
  5. aboogoost

    aboogoost

    Joined:
    Nov 6, 2016
    Posts:
    10
    Where would be the best place to inquire further about this?
     
  6. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,924
    All you can do at the moment is submit a bug report, I think.

    My reading of the current front page of hte docs is that this isn't currently implemented -- the docs say it's not possible, while the flags are there in the classes (feels like a half-done implementation / upgrade). That's to be expected given this is a preview build, I think.

    Personally ... I find it difficult to see when/why you'd want simultaneous selection in a normal game - but I agree that if it's possible (and based on my dives into the source code I think it is possible, with tiny changes) it should be allowed! But if I'm struggling with seeing your use-case, the unity guys would probably struggle even more (most of them aren't working on actual games, so they don't see the same problems/needs we see). Maybe make a simple project that shows how/why/what you're trying to do in the simplest sense, then upload that as a bug-report, and see what resposne you get?

    (that way they've got the context on why/what you're trying to do too, which is probably helpful)
     
    aboogoost likes this.
  7. aboogoost

    aboogoost

    Joined:
    Nov 6, 2016
    Posts:
    10
    Thank you for your response! Where would I file a bug?

    Can you point me to this? I thought I had read through all the docs but didn't see this. It's no biggie if it isn't yet implemented, I just didn't see anything that indicates this.

    For example if you want to grab and object to move it around but then grab it with both hands to resize it by "stretching" it.
     
  8. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,924
    Create a new empty project, make the simplest example you can think of that shows the wrong behaviour, and then use the menu "Help > Submit a Bug" (and make sure you save this project somewhere! Because Unity may need you to re-send it to them in future if they have difficulty reproducing the bug). This will send the project to Unity, and create a bug report in their system.

    About 2/3 down, there's a tiny short paragraph about XR Interaction Manager and how it is implemented. Sadly, it omits a lot of information (e.g. in the source code there are references to different "phases" that it performs, which is undefined in the docs), but it has a bit which talks explicitly about how Selects are first cancelled before new ones come in, and makes it sound like that's a hardcoded design.

    LMAO this is almost exactly what I spent all weekend trying to make work (and couldn't - too many bugs / missing parts of the API right now). It's definitely possible if you write your own replacement for some/several of the XRIT classes, but I was trying to do it using their provided classes, and that doesn't work.

    NB: my case was actually a bit easier than yours: I was splitting the object on grab, so that there was never simultaneous selection (instead, there were two new objects, one in each hand). So you should still go ahead and submit a basic example / bug report!

    I got it to half work, but only by having the objects swap hands when you split them - which is the opposite of what the player expects :). You can see some of the issues I ran into (some of them are bugs, others are missing features I needed for this), and workarounds, in page 7 of the main thread: https://forum.unity.com/threads/xr-interaction-toolkit-preview-release.795684/page-7
     
    aboogoost likes this.
  9. aboogoost

    aboogoost

    Joined:
    Nov 6, 2016
    Posts:
    10
    Thank you!

    Do you mean the graphic titled "Extending The XR Interaction Toolkit" on this page?
     
  10. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,924
    More the bit above that, titled "Update loop" - but the docs on this are terrible. There is a tonne of required info on InteractionManager (which the docs even refer to elsewhere, telling you to read the InteractionManager docs), but the InteracitonManager docs are missing in this release - just literally nothing there.

    (It feels as though the team shipped this release without checking the docs first, and accidentally deleted the IM docs at least. I'm hoping this will get noticed / fixed before the final release)
     
  11. ratozumbi

    ratozumbi

    Joined:
    Oct 31, 2016
    Posts:
    3
    I need to select an object with two hands so that I can scale the object using the hands distance.
    The way I see, the only possible solution is to make my own Interactor deriving from XRBaseInteractor and have my own reference for interactors, so that I can compare the parameter interactor with my interactors list to ignore onExit events if another interactor is interacting
    (if any Unity dev team reads this, PLEASE consider changing those class names)
     
  12. Jeshira

    Jeshira

    Joined:
    Aug 3, 2017
    Posts:
    12
    For the particular case of model transform like resize you could simply have a fake grab. Have a script that on grip hold from both controllers takes distance delta between controllers. Best work with some menu to select appropriate transform or axis.

    That said, we'd be more likely to have multiple grip holds with a grip manager than having two grapplers catch the same grip which is like holding the same handle of a bag.

    As is XRTK 0.10.0, you could have multiple grab interactable as children of an empty gameObject at key points around your form, also children of that GO. As is, you can grab the interactable and move it within parent's local space. Then with a main script do some math to apply any transformation that would match new key point position relative first grab.

    Example : Grab left side grip, then right side grip. Center form between them, resize form to distance between those grips. Don't forget to reposition other grips.

    Extra points : You could make it as a tool to which you child any form you select.
     
    Last edited: Jan 3, 2021
  13. tlskillman

    tlskillman

    Joined:
    Dec 12, 2015
    Posts:
    16
    On the two hand grab functionality, I'd like to see this too. Best info I've found so far is this video which handles the two hand grab and rotate, but doesn't address scaling. Source code is behind paywall. If anyone out there has XR code for this functionality, and willing to share, please do!