Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ARCore collider on generated planes

Tags:

unity3d

arcore

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?

like image 402
Duncan Roberts Avatar asked Aug 30 '17 14:08

Duncan Roberts


People also ask

What is a plane manager?

The plane manager is a type of trackable manager. The plane manager creates GameObjects for each detected plane in the environment. A plane is a flat surface represented by a pose, dimensions, and boundary points. The boundary points are convex.

What is AR core in Unity?

ARCore provides two different SDKs for using Unity to develop AR apps for Android. AR Foundation with ARCore XR Plugin, and ARCore Extensions — Recommended for all new projects.


2 Answers

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!

like image 177
Jonas Johansson Avatar answered Sep 25 '22 01:09

Jonas Johansson


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.

Plane with Collider Screenshot

like image 23
atomarch Avatar answered Sep 23 '22 01:09

atomarch