AR Foundation ARKIT gameobjects placed on mesh drift

Hi,
I use AR foundation and ARKIT and IPAD with LIDAR on unity 2020.3.13f1.
How to prevent drift of gameobjects on the mesh.
First image I instantiated some sphere and continue to scan the place. After going back to my initial position sphere drifted a lot. Why this is moving ?

the update function:

if(isActivate)
        {           
            if(Input.touchCount > 0)
            {
                Touch touch = Input.GetTouch(0);
           
                if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
                {
                    Debug.Log("Touched the UI");
                    return;
                }
           
                touchPosition = touch.position;

                if(touch.phase == TouchPhase.Began)
                {
                    Ray ray = origin.camera.ScreenPointToRay(touch.position);
                    RaycastHit hitObject;
                    if(Physics.Raycast(ray, out var hit, float.PositiveInfinity, 1 << meshManager.meshPrefab.gameObject.layer))
                    {
                        lastSelectedObject = hit.transform.GetComponent<PlacementObject>();
                        if(lastSelectedObject != null)
                        {
                            PlacementObject[] allOtherObjects = FindObjectsOfType<PlacementObject>();
                            foreach(PlacementObject placementObject in allOtherObjects)
                            {
                                placementObject.Selected = placementObject == lastSelectedObject;
                            }
                        }
                    }
                }

                if(touch.phase == TouchPhase.Ended)
                {
                    lastSelectedObject.Selected = false;
                }
            }

            for (int i = 0; i < Input.touchCount; i++)
            {
                var touch = Input.GetTouch(i);
                var ray = origin.camera.ScreenPointToRay(touch.position);
                var hasHit = Physics.Raycast(ray, out var hit, float.PositiveInfinity, 1 << meshManager.meshPrefab.gameObject.layer);
                if (hasHit)
                {
                    if(lastSelectedObject == null)
                    {
                        lastSelectedObject = Instantiate(placedPrefab, hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal)).GetComponent<PlacementObject>();
                       
                        points.Add(lastSelectedObject.transform);
                        line.SetupLine(points);
                    }
                    else
                    {
                        if(lastSelectedObject.Selected)
                        {
                            lastSelectedObject.transform.position = hit.point;
                            lastSelectedObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
                        }
                    }
                }
            }
        }

Best,

You can use AR Anchors to keep the objects in place. :slight_smile:

Yeah I thought about it, does AR Anchors works with mesh manager ?

Hi,

I’m also in charge of the development of this app.

So my understanding of Anchor points are they make virtual objects move when either feature points or planes moves. Are they binded to the ARKit ARAnchor system?

I tried different things with the Unity ARFoundation demo project, mostly with the Anchor demo.
I ended with the same issue by reproducing the movements done as described in the previous post, both the plane based and the feature point based anchors drifted from their original positions.

I guess that that’s a limitation we can’t completely overcome. We need to be cautious about the kind of movements we make during the process by considering safer tracking patterns and the way we hold the device. I am trying to define the kind of movements to adopt in order to reduce all those issues.

What are the additional tips you can give?

This could be a potential AR Foundation issue. Please report a bug.