Arcore-unity-sdk: How to select an already placed 3D object through Raycasting?

Created on 28 Feb 2018  路  4Comments  路  Source: google-ar/arcore-unity-sdk

I want to select an object through Raycasting in ARCore Unity in HelloAR example (The one where we put Andy GameObject on horizontal planes). Once I have placed the object in the real world, I want to select it so I can manipulate it using code. I've tried the traditional Unity method, but it doesn't work. Then I tried using TrackableHit with Frame.Raycast, but the resultant hit doesn't really tell if it has collided with a GameObject; it only tells you about the position of the hit....Any workaround for this? Or something I'm missing? I'm stuck...

Most helpful comment

Hi, if you want the "traditional Unity method" (I guess it's Phisycs.Raycast) I believe you'll have to add a collider to the GameObject.
Frame.Raycast will only return hits for the flag you pass to it which can be a Plane or Feature point. It's not intended to use it with user created game objects, only with ARCore internal objects (which currently are detected planes and feature points).

All 4 comments

Hi, if you want the "traditional Unity method" (I guess it's Phisycs.Raycast) I believe you'll have to add a collider to the GameObject.
Frame.Raycast will only return hits for the flag you pass to it which can be a Plane or Feature point. It's not intended to use it with user created game objects, only with ARCore internal objects (which currently are detected planes and feature points).

I think Raycasting from ARCore (Frame.Raycast) is not that same thing as Raycast of UnityEngine. I think Raycast of ARcore might not work with Andy. Maybe you can try Physics.Raycast.

Given the thumbs up, I'm closing this issue because I think it's resolved. Please reopen if you still have the issue.

another thing easily getting wrong is, use the arcore camera to construct the ray instead of camera.main.

Was this page helpful?
0 / 5 - 0 ratings