[Bug]ARRaycastManager.Raycast(Ray) doesn’t work based on subsystem.Raycast
About using ARRaycastManager.Raycast() in iOS. In case of using Ray (from Screen Pos direction to Camera) as the first argument, it doesn't work base on subsystem raycast (it means arkit raycast). Now it seems to work only based on ARFoundation's trackable raycast.
procedure
- Open Anchors Scene in Unity.
- Open AnchorCreator.cs in a script editor.
- Change Update Function as bellow (change 1, change 2).
void Update()
{
if (Input.touchCount == 0)
return;
var touch = Input.GetTouch(0);
if (touch.phase != TouchPhase.Began)
return;
// ###### Create Ray from screen pos ###### .... change 1
Ray ray = Camera.main.ScreenPointToRay(touch.position);
// Raycast against feature points
const TrackableType trackableTypes =
TrackableType.FeaturePoint;
// ###### Change first argument of Raycast ###### .... change 2
if (m_RaycastManager.Raycast(ray, s_Hits, trackableTypes))
{
// Raycast hits are sorted by distance, so the first one will be the closest hit.
var hit = s_Hits[0];
// Create a new anchor
var anchor = CreateAnchor(hit);
if (anchor)
{
// Remember the anchor so we can remove it later.
m_Anchors.Add(anchor);
}
else
{
Logger.Log("Error creating anchor");
}
}
}
- Build and Run
Actual behavior I think it should work the same for both argument ( Vector2 , Ray ).
Smartphone (please complete the following information):
- Device: iPhone11 Pro
- OS: iOS 14.6
- Unity version 2020.3.11
- ARFoundation version 4.2.0-pre.9
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
ARKit doesn't support this interface, so the ARRaycastManager uses a fallback implementation provided by AR Foundation. However, it can only raycast against things it knows about. To make it aware of feature points, add an ARPointCloudManager to the ARSessionOrigin.
Most of the AR managers "turn on" features, e.g., the ARPlaneManager enables plane detection. However, ARKit always has feature points available internally, while AR Foundation is only aware of them if you "enable" them with the point cloud manager. This means that ARKit's native raycast method (using a screen point) can always use feature points, while AR Foundation can only use them if you enable the point cloud manager.
Thank you for detail information. I understand it ! Could you add information to ARFoundation documentation ? It helps developers to understand.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.