What is the difference between the different .Plane-TrackableTypes? The definitions seem pretty vague to me. For instance, PlaneEstimated? Like, if it isn't actually a plane, what is it, and how does it work? Since there is already PlaneWithinInfinity, which to me, sounds almost the same. Also, the difference between PlaneWithinPolygon and PlaneWithinBounds? Lastly, is there a logic behind using just TrackableType.Planes? Should this be used alone, or is it just to get all the possible plane trackable types in the ARRaycastHit?
"Estimated" means the plane has an imprecise boundary. On ARKit, for example, it corresponds to ARHitTestResultTypeEstimatedHorizontalPlane. "Within Infinity" means to raycast against the infinite plane. "Within Polygon" means the ray must hit somewhere inside the boundary points of the plane. "Within Bounds" means the ray must hit somewhere inside the 2d bounding box of the plane (the rectangle that encloses the boundary points). TrackableType.Planes means any of the above.
Thanks! So if we were to order them in size, it would go: PlaneWithinPolygon < PlaneEstimated < PlaneWithinBounds < PlaneWithinInfinity Does TrackableType.Planes prioritise which plane type should be used and always fall back to the most reliable one in this order? e.g If there is two planes of different height positions, when hitting the lower plane, will it filter out the top plane's PlaneWithinInfinity? ect...
It's more like PlaneWithinPolygon < PlaneWithinBounds < PlaneEstimated < PlaneWithinInfinity. The trackable type parameter is a filter, not a priority. For example, if you specify PlaneWithinPolygon and PlaneWithinInfinity, and the hit point is within the plane's polygon, then you would have one hit whose hitType is PlaneWithinPolygon | PlaneWithinInfinity. If multiple planes intersect the ray, then you would get multiple hits, with the appropriate flags set on each hit's hitType. The results are sorted by distance from the raycast origin.
Some documentation to the above effect would be nice, I also hit this part of AR raycasting and the vagueness was a head scratcher. It would also be great if the underlying enum value could be ordered so that they ran from most the least specific so we can more easily sort by hit type: Code (CSharp): hits.OrderBy(x => x.hitType).ThenBy(x => x.distance).First(); to grab the most specific hit in the list.
Hi All, Sorry to jump on an old thread, but I am really struggling to remove an AR placed object using physics raycast in AR FOUNDATION 4.1 and oddly can't see find much on it which is obviously me. My logic is to check if a physics raycast hits an object with tag (so must have been placed) then remove it. If it hits a plane using the ARraycast then spawn the object in place. I feel its something to do with the main camera? I have used ar session camera and tagged it as main. I can delete using a UI interface but want to click and hold on the placed object? Below are two separate attempts but none of the physics raycasts seem to hit anything? Code (CSharp): if (Input.touchCount > 0) { Touch touch = Input.GetTouch(0); if (touch.phase == TouchPhase.Began) { var touchPosition = touch.position; bool isOverUI = touchPosition.IsPointOverUIObject(); if (isOverUI) { Debug.Log(" blocked raycast"); return; } Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position); RaycastHit hit; if (Physics.Raycast(ray, out hit) && (hit.transform.tag == "knight")) { Debug.Log(" raycast"); if (Input.GetTouch(0).deltaTime > 0.2f) { Destroy(hit.transform.gameObject); } } else if (!isOverUI && arRaycastManager.Raycast(touchPosition, hits, UnityEngine.XR.ARSubsystems.TrackableType.Planes)) { Debug.Log(" arraycast"); var hitPose = hits[0].pose; Instantiate(placedPrefab, hitPose.position, hitPose.rotation); } } } I have also tried the following which places but then will not remove. Code (CSharp): void Update() { if (Input.touchCount > 0) { var touch = Input.GetTouch(0); if (touch.phase == TouchPhase.Ended) { if (Input.touchCount == 1) { //Rraycast Planes if (arRaycastManager.Raycast(touch.position, arRaycastHits)) { var pose = arRaycastHits[0].pose; CreateKnight(pose.position); return; } Ray ray = Camera.main.ScreenPointToRay(touch.position); if (Physics.Raycast(ray, out RaycastHit hit)) { if (hit.collider.tag == "knight") { DeleteKnight(hit.collider.gameObject); } } } } } } /code] Thanks for any pointers.
Hey @wayne_christian - this is more a physics questions, it's recommended that you create a new thread over on our Physics forums.
Hi Treyk-47, thanks for the reply. I resolved in the end. There was an issue with my AR FOUNDATION set up. Cheers
Hi, So for example, if I want to spawn a 3D object onto another one (Place one 3D model onto another). What plane type should I use? I have attached a picture of what I am talking about. Could someone please help me out?