How to find play area from XR interaction toolkit

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.

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:

private void Awake()
    {
            List<XRInputSubsystem> list = new List<XRInputSubsystem>();
            SubsystemManager.GetInstances<XRInputSubsystem>(list);
            foreach (var sSystem in list)
            {
                if (sSystem.running)
                {
                    _inputSubSystem = sSystem;
                    break;
                }
            }
            _inputSubSystem.boundaryChanged += RefreshBoundaries;
    }

    private void RefreshBoundaries(XRInputSubsystem inputSubsystem)
    {
            List<Vector3> currentBoundaries = new List<Vector3>();
            //if (UnityEngine.Experimental.XR.Boundary.TryGetGeometry(currentBoundaries))
            if (inputSubsystem.TryGetBoundaryPoints(currentBoundaries))
            {
                //got boundaries, keep only those which didn't change.
                if (currentBoundaries != null && (_boundaries != currentBoundaries || _boundaries.Count != currentBoundaries.Count))
                    _boundaries = currentBoundaries;
                DrawWalls();
            }
    }

Ok, it works on Quest, but not with Link…

Yes, boundary info currently does not work via Oculus Link.

Do you know maybe an ETA? This looks like a much requested feature.

I also need this.

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?

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!

public class Scenestart : MonoBehaviour
{
    private XRInputSubsystem _inputSubSystem;
    private List<Vector3> _boundaries;
    // Start is called before the first frame update
    void Start()
    {
        getPlayArea();
    }

    // Update is called once per frame
    void Update()
    {
        if (_inputSubSystem == null)
            VRAwake();
    }

    void VRAwake()
    {
        List<XRInputSubsystem> list = new List<XRInputSubsystem>();
        SubsystemManager.GetInstances<XRInputSubsystem>(list);
        foreach (var sSystem in list)
        {
            if (sSystem.running)
            {
                _inputSubSystem = sSystem;
                break;
            }
        }
        if (_inputSubSystem != null)
            _inputSubSystem.boundaryChanged += RefreshBoundaries;
    }

    private void RefreshBoundaries(XRInputSubsystem inputSubsystem)
    {
        List<Vector3> currentBoundaries = new List<Vector3>();
        //if (UnityEngine.Experimental.XR.Boundary.TryGetGeometry(currentBoundaries))
        if (inputSubsystem.TryGetBoundaryPoints(currentBoundaries))
        {
            //got boundaries, keep only those which didn't change.
            if (currentBoundaries != null && (_boundaries != currentBoundaries || _boundaries.Count != currentBoundaries.Count))
                _boundaries = currentBoundaries;
            Debug.Log("DrawWalls()");
        }
    }

}
1 Like

@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?

Thank you, this worked for me

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?