Search Unity

How to find play area from XR interaction toolkit

Discussion in 'XR Interaction Toolkit and Input' started by dfkan12, Aug 3, 2020.

  1. dfkan12

    dfkan12

    Joined:
    Nov 1, 2017
    Posts:
    15
    For a VR experience I am making, I am using the XRInputSubsystem.TryGetBoundaryPoints to map the guardian of the Oculus Quest. I have managed to get the points of the boundary.

    Can someone help tell, how do I map these boundary points to a 4 point shape (rectangle) with width and length? Also how can I use it to correct and reset the recentering of the world in the Quest when it drifts off from the recenter - thus keep the world origin always in the center of the guardain?

    A small note, we know there is OVR manager from Oculus, but we are making a cross platform experience so that's why we are using Unity's XR plugin.
     
  2. gabe87hun

    gabe87hun

    Joined:
    Jan 16, 2014
    Posts:
    3
    Hi,

    I'm trying to get boundar points too, but XRInputSubsystem.TryGetBoundaryPoints doesn't give me anything. Could you please elaborate on how did you use the method? Mine looks like this:

    Code (CSharp):
    1. private void Awake()
    2.     {
    3.             List<XRInputSubsystem> list = new List<XRInputSubsystem>();
    4.             SubsystemManager.GetInstances<XRInputSubsystem>(list);
    5.             foreach (var sSystem in list)
    6.             {
    7.                 if (sSystem.running)
    8.                 {
    9.                     _inputSubSystem = sSystem;
    10.                     break;
    11.                 }
    12.             }
    13.             _inputSubSystem.boundaryChanged += RefreshBoundaries;
    14.     }
    15.  
    16.     private void RefreshBoundaries(XRInputSubsystem inputSubsystem)
    17.     {
    18.             List<Vector3> currentBoundaries = new List<Vector3>();
    19.             //if (UnityEngine.Experimental.XR.Boundary.TryGetGeometry(currentBoundaries))
    20.             if (inputSubsystem.TryGetBoundaryPoints(currentBoundaries))
    21.             {
    22.                 //got boundaries, keep only those which didn't change.
    23.                 if (currentBoundaries != null && (_boundaries != currentBoundaries || _boundaries.Count != currentBoundaries.Count))
    24.                     _boundaries = currentBoundaries;
    25.                 DrawWalls();
    26.             }
    27.     }
     
  3. gabe87hun

    gabe87hun

    Joined:
    Jan 16, 2014
    Posts:
    3
    Ok, it works on Quest, but not with Link...
     
  4. mfuad

    mfuad

    Unity Technologies

    Joined:
    Jun 12, 2018
    Posts:
    335
    Yes, boundary info currently does not work via Oculus Link.
     
  5. gabe87hun

    gabe87hun

    Joined:
    Jan 16, 2014
    Posts:
    3
    Do you know maybe an ETA? This looks like a much requested feature.
     
  6. hasseyg

    hasseyg

    Joined:
    Nov 16, 2013
    Posts:
    81
    I also need this.
     
  7. rotxyz

    rotxyz

    Joined:
    Mar 26, 2018
    Posts:
    7
    I'm using a Quest via Link and running into an issue where TryGetBoundaryPoints() returns the boundary points for the play area that I set with my Rift. Is this the same problem?
     
  8. hgabor47

    hgabor47

    Joined:
    Mar 21, 2015
    Posts:
    1
    almost done.
    I think, the subsystem wake up later.
    I renamed the AWAKE method, and insert it into UPDATE with an if condition.
    It is worked for me!

    Code (CSharp):
    1. public class Scenestart : MonoBehaviour
    2. {
    3.     private XRInputSubsystem _inputSubSystem;
    4.     private List<Vector3> _boundaries;
    5.     // Start is called before the first frame update
    6.     void Start()
    7.     {
    8.         getPlayArea();
    9.     }
    10.  
    11.     // Update is called once per frame
    12.     void Update()
    13.     {
    14.         if (_inputSubSystem == null)
    15.             VRAwake();
    16.     }
    17.  
    18.     void VRAwake()
    19.     {
    20.         List<XRInputSubsystem> list = new List<XRInputSubsystem>();
    21.         SubsystemManager.GetInstances<XRInputSubsystem>(list);
    22.         foreach (var sSystem in list)
    23.         {
    24.             if (sSystem.running)
    25.             {
    26.                 _inputSubSystem = sSystem;
    27.                 break;
    28.             }
    29.         }
    30.         if (_inputSubSystem != null)
    31.             _inputSubSystem.boundaryChanged += RefreshBoundaries;
    32.     }
    33.  
    34.     private void RefreshBoundaries(XRInputSubsystem inputSubsystem)
    35.     {
    36.         List<Vector3> currentBoundaries = new List<Vector3>();
    37.         //if (UnityEngine.Experimental.XR.Boundary.TryGetGeometry(currentBoundaries))
    38.         if (inputSubsystem.TryGetBoundaryPoints(currentBoundaries))
    39.         {
    40.             //got boundaries, keep only those which didn't change.
    41.             if (currentBoundaries != null && (_boundaries != currentBoundaries || _boundaries.Count != currentBoundaries.Count))
    42.                 _boundaries = currentBoundaries;
    43.             Debug.Log("DrawWalls()");
    44.         }
    45.     }
    46.  
    47. }
    48.  
     
    jjmontes likes this.
  9. Akura

    Akura

    Joined:
    Jun 28, 2015
    Posts:
    23
    @hgabor47 Does your code also work when you use the link cable? When I use your CSharp Code my "_boundaries" are always at a Count of "0". Could you also share your getPlayArea(); which you call in the Start() function?
     
  10. Murray_Zutari

    Murray_Zutari

    Joined:
    Jun 1, 2017
    Posts:
    45
    Thank you, this worked for me
     
  11. MarkAllen

    MarkAllen

    Joined:
    Jan 10, 2017
    Posts:
    1
    An old thread I know, but if you use the above method, and then take the headset off, let it power down, then move sightly and put the headset back on, the boundary points do not update to the new position the player is in. And therefore what you show in the game is incorrect. Does anyone have a way of getting the new points, without spamming the TryGetBoundaryPoints every frame?