Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to make plane mesh colliders?

Discussion in 'AR' started by edwon, Aug 1, 2018.

  1. edwon

    edwon

    Joined:
    Apr 24, 2011
    Posts:
    266
    I want to have colliders that match the shape of the "plane meshes" from ARKit 1.5.

    aka I need the collider to match the detailed mesh you can render

    I tried passing in the created mesh to a mesh collider and updating it every time arkit updates it, but no luck, it's just always square.

    This is what I did, I modified ARKitPlaneMeshRender

    Code (CSharp):
    1.     public void InitiliazeMesh(ARPlaneAnchor arPlaneAnchor)
    2.     {
    3.         planeMesh = new Mesh ();
    4.         UpdateMesh (arPlaneAnchor);
    5.         meshFilter.mesh = planeMesh;
    6.  
    7.         // must null the mesh collider before assigning to fully refresh
    8.         meshCollider.sharedMesh = null;
    9.         meshCollider.sharedMesh = planeMesh;
    10.     }
     
  2. alphadogware

    alphadogware

    Joined:
    Nov 15, 2017
    Posts:
    76
    did you figure this out?
     
  3. edwon

    edwon

    Joined:
    Apr 24, 2011
    Posts:
    266
    nope, still waiting for unity to figure this out for us

    however I did do a test with the new ARFoundation package the other day, and the mesh colliders work perfectly on their planes (which are not just planes, but mesh planes that adapt to the shape of the flat surface)

    https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@1.0/manual/index.html
     
  4. alphadogware

    alphadogware

    Joined:
    Nov 15, 2017
    Posts:
    76
    I got it to work for what I needed by using the demo scene from ARKit 2.0 and changing the collider in the Plane in debugPlanePrefab in the UnityARKitPlugin\Examples\Common\Prefabs folder.

    Objects I was placing on the generated planes were falling though. I added a box collider to the Plane object and changed the y size to 0.2. Boom, things stopped dropping through the plane.

    Don't know if this helps with your issue, but it fixed mine.
     
  5. edwon

    edwon

    Joined:
    Apr 24, 2011
    Posts:
    266
    A plane collided is different than a mesh collider. This thread is specifically about mesh colliders that can match the non-square flat shapes that ARKit 2.0 can detect.
     
  6. alphadogware

    alphadogware

    Joined:
    Nov 15, 2017
    Posts:
    76
    Just trying to give an alternate option to the issue. Didn't mean to trespass on your 'plane collider-only' thread.
     
    TSStefan likes this.