Hi,
is there any other way than ARSession.Reset() to remove trackables (ARPlanes specifically).
I’m talking about having them removed from being tracked in the subsystem, such that they wont be hit by raycasts anymore.
I want to achieve a cleanup of the AR scene as sometimes in longer sessions some of the planes have significant offset/rotation which are useless when trying to scan a code on the plane.
I don’t like using the ARSession.Reset() to achieve this, cause it disrupts the camera feed, and sometimes on the Samsung Galaxy S9 the feed never comes back unless you restart the app.
Thanks for the answer,
yes I am aware that one may disable the plane GameObjects, so they wont be shown, but the planes within the subsystem are still hit by ARRaycastManager.Raycast()
so basically if i want to ignore old planes I’d have to have a mesh collider on the planes, deactivate all old ones and perform Physics.Raycast(), correct?
You can find ARPlane by its trackable id with the help of ARPlaneManager.GetPlane(). And then check if that plane is enabled. Here is a quick example. Could you please try it and tell if my assumption is correct?
var origin = FindObjectOfType<ARSessionOrigin>(); // todo cache
var ray = origin.camera.ScreenPointToRay(touch.position);
var hits = new List<ARRaycastHit>();
var raycastManager = FindObjectOfType<ARRaycastManager>(); // todo cache
var hasHit = raycastManager.Raycast(ray, hits, trackableTypeMask);
if (hasHit) {
var planeManager = FindObjectOfType<ARPlaneManager>(); // todo cache
var index = hits.FindIndex(_ => planeManager.GetPlane(_.trackableId)?.gameObject.activeSelf ?? false);
if (index != -1) {
var hit = hits[index];
// do something with hit
}
}
Thanks, I tried this, and in general it works, however, what I didn’t think about last week:
With this approach the raycast might miss “good” planes which don’t get updated anymore.
So i guess the AR session reset is the only option.