Spatial tap gesture not recognized on AR planes

I have been working with the template and samples and I am trying to spawn an object on an AR plane by looking at an AR plane and then performing a spatial tap (indirect pinch). But I am having issues recognizing/registering an indirect pinch on any AR plane. It seems that the colliders may not be valid on ARKit planes when trying to select them with the spatial tap gesture?

are you in volume mode or immersive. in volume arkit does not work.

This is supported and functionally should work with the script below. If anyone is also running into this issue check the layer of the AR Default Plane. For the package samples it’s using a layer that isn’t set so it gets imported as a missing layer and thus no longer gets collision data. I’ll try to land a fix for the next release!

public class PlaceOnPlane : MonoBehaviour
{
    [SerializeField]
    GameObject m_PrefabToPlace;

    void OnEnable()
    {
        EnhancedTouchSupport.Enable();
    }

    void Update()
    {
        var activeTouches = Touch.activeTouches;

        if (activeTouches.Count > 0)
        {
            var primaryTouchData = EnhancedSpatialPointerSupport.GetPointerState(activeTouches[0]);
            if (activeTouches[0].phase == TouchPhase.Began)
            {
                if (primaryTouchData.Kind == SpatialPointerKind.IndirectPinch)
                {
                    var planeObject = primaryTouchData.targetObject;
                    if (planeObject != null)
                    {
                        // make sure it's an AR Plane
                        if (planeObject.TryGetComponent(out ARPlane arplane))
                        {
                            Instantiate(m_PrefabToPlace, primaryTouchData.interactionPosition, Quaternion.identity);
                        }
                    }
                }
            }
        }
    }
}

This is a good bug catch that otherwise has people believing it’s another feature not yet implemented

Yep, that fixes the issue. It was just that the ARPlane prefab was not listed on any layer, so even just putting it on the Default layer allowed it to be found.

Hi, @DanMillerU3D / @brian_bare , I had the same issue and thanks for the discussion/solution, changing layer to Default seems to be working!

But could you please elaborate a bit more on this? I saw the original prefab is on layer “Placeable Surface”, which is a valid layer in Unity. But looks like it is not registered with visionOS? If so, could you let us know what is the proper way to register a Unity layer to be able to interact with visionOS user inputs, such as Spatial Tap, etc. ?

I think this is true for the template but not the package samples (which have it set to a invalid layer and appears as a blank box).

For making sure colliders get “sent over” the PolySpatial bridge to visionOS you should check the Collider Objects Layer Mask in the PolySpatial settings. If the layer is in there it should come through on visionOS.

Thanks a lot @DanMillerU3D , that explains the confusion and it worked!