ARCore collider on generated planes

2019-02-15 15:15发布

问题:

I'm just playing around with AR core and want to have an object flying around the room and able to land. I'm unsure about how to add colliders to the planes that ARcore is generating based on the visuals on the room. Would this involve instantiating box colliders on the planes somehow?

回答1:

The ARCore SDK's trackable planes are essentially identified flat surfaces such as the ground or a tabletop.

You can ask the SDK for a list of points for each trackable plane's boundary polygon (retrieved in clockwise order) and create a mesh from those points via triangulation. With the mesh ready, create a GameObject and add a MeshCollider component that references it.

I've created a free Unity plugin that does exactly this. Feel free to use it: https://github.com/jonas-johansson/ARCoreUtils.

I hope that helps!



回答2:

Assuming you are doing this in Unity, you may want to use a Mesh Collider on the surface instead of a Box Collider.

I'm not sure about ARCore in Unity specifically, but in other AR frameworks it works something like in the attached screen shot, so I imagine it would be similar.



回答3:

Adding a rigid body to the object causes gravity to be applied set gravity to 0 on the object rigid bidy. That will stop it falling away