We are facing some issues with drifting/positioning and elevation problems with a model placed on an AR Plane. Our model is bigger than the average 3d model used in Unity (20+MB, with around 1M Tris and Verts) and is parented to an empty GameObject which acts as our pivot point and then instantiated at the plane.
We tried a lot of things on Unity’s side like changing Lighting settings, camera settings, project settings but nothing helps.
We tried executing the placement of the object in different ways (in Update function, in a separate co-routine and then stopping the co-routine), but that doesn’t help either. We tried updating the plugins but XR-Management plugin doesn’t allow us to do it (known issue: https://answers.unity.com/questions/1795233/unity-hdrp-giving-error.html?_ga=2.79868369.777550575.1615883600-516132349.1615883600) so we are basically stuck with 4.1.1. We are facing the same kind of drifting on both Android and iOS devices.
Please let us know how to debug the cause of the drifting, we would appreciate it immensely.
Plug-ins and Tool Versions :
Unity Editor: 2020.1.8f1 AR Foundation : 4.1.1 ARKit : 4.1.1 ARCore : 4.1.1 XR-Plugin Management : 3.2.16
Probably should have mentioned this, but we have already tried adding an ARAnchor component to the parent object as suggested in the AR Foundation documentation :
if (parent.GetComponent<ARAnchor>() == null)
{
parent.AddComponent<ARAnchor>();
}
We still see the same kind of drifting even after adding the ARAnchor component. Thanks for the response.
Have you checked the performance of the application while running on the device?
I’m guessing the object is stressing your device, which might reduce the number of updates that ARKit/ARCore are able to perform (per second), by pushing them to a ‘background-thread’ in the OS. This would result in less accurate positioning.
@FrankvHoof What exactly do we need to look for while profiling the application? (FPS/GPU Draw Calls/Memory Usage or is it something more specific to ARKit/ARCore?)
@danUnity_1 We have tried the same with a simple cube and a sphere; they have the same kind of drifting. The drifting is horizontal.
Can you please elaborate on this? That would be very helpful.
Well if you have the same issue with a simple cube then it’s not the fps the issue. What your fps when running the profiler?
You have to make sure your object is sitting right on top of the ARplane otherwise you’ll get displacement when moving the camera in AR.
You should buy the asset AR foundation remote on the asset store if you are serious about this since it will allow you to test all that very quickly and see the issue quickly too within the editor.
We get a steady 60 FPS before placing the model and after placing we get around 40-45 FPS.
How do we check that the object is sitting on top of the AR Plane? We are instantiating the model at the AR Plane position using an AR Raycast, as suggested in the documentation.
Thanks for the suggestion, we will check this asset, it would definitely help.
To check if it sits on it, you could change the ARplane shader to be able to view it and then after you instantiated the object, you move your camera down to the floor to see if it’s directly on top of it.
The AR Foundation Remote would definitely help with that task.
If you’re using Unity 2020, you should upgrade to Unity 2020.3, which is the LTS version.
If the model is heavy enough to cause a drop below 60fps, that will negatively impact AR tracking. Simplifying the model to be lighter to achieve 60fps should improve AR tracking quality.