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

ARCore collider on plane generator

Discussion in 'AR' started by robrtoprz, Jul 4, 2018.

  1. robrtoprz

    robrtoprz

    Joined:
    May 15, 2017
    Posts:
    9
    Hi, is there a way to make the generate plane collide with the objects? I'm placing objects in my scene pressing a button but when I place them they falls down.

    I saw that exists the ARCoreUtils, but works with the ARCore v1.1, I didn't get to work with the ARCore v1.3.0.

    Thanks.
     
  2. AbdulMoeedAhmed

    AbdulMoeedAhmed

    Joined:
    Sep 5, 2013
    Posts:
    2
    Hello, I am also facing same issue yes in the mid of 2019 :( I have seen and used ARCoreUtils , it works fine for me when instantiating a simple prefab! I am facing a problem when using it in ObjectManipulation scene in ARCore Examples. Unable to instantiate a prefab with default script "AndyPlacementManipulator", while "ObjectManipulationController" and "ManipulationSystem" are active gameobjects in the hierarchy.

    Does anyone found a solution for updated ARCore versions? I am using ARCore v1.9.0!
     
  3. AbdulMoeedAhmed

    AbdulMoeedAhmed

    Joined:
    Sep 5, 2013
    Posts:
    2
    After a little struggle.. found a solution! Create a MeshCollider inside a "DetectedPlaneVisualizer.cs" sciprt and assign it as shared mesh.
    //Declare a MeshCollider inside DetectedPlaneVisualizer.cs
    private MeshCollider ar_meshCollider;

    //Initialize inside Awake() function
    ar_meshCollider = GetComponent<MeshCollider>();

    //Assign as shared mesh inside _UpdateMeshIfNeeded() function
    ar_meshCollider.sharedMesh = m_Mesh; //(used for collision detection)


    Or simply just replace this script inside your AR Core Example Project.
     

    Attached Files:

    davidborbis likes this.
  4. kshoukry

    kshoukry

    Joined:
    Nov 19, 2016
    Posts:
    3
    Have you tried in ARFoundation 4preview? ARPlaneMeshVisualizer.cs already has similar code:
    Code (CSharp):
    1.             var boundary = m_Plane.boundary;
    2.             if (!ARPlaneMeshGenerators.GenerateMesh(mesh, new Pose(transform.localPosition, transform.localRotation), boundary))
    3.                 return;
    4.  
    5.             var lineRenderer = GetComponent<LineRenderer>();
    6.             if (lineRenderer != null)
    7.             {
    8.                 lineRenderer.positionCount = boundary.Length;
    9.                 for (int i = 0; i < boundary.Length; ++i)
    10.                 {
    11.                     var point2 = boundary[i];
    12.                     lineRenderer.SetPosition(i, new Vector3(point2.x, 0, point2.y));
    13.                 }
    14.             }
    15.  
    16.             var meshFilter = GetComponent<MeshFilter>();
    17.             if (meshFilter != null)
    18.                 meshFilter.sharedMesh = mesh;
    19.  
    20.             var meshCollider = GetComponent<MeshCollider>();
    21.             if (meshCollider != null)
    22.                 meshCollider.sharedMesh = mesh;
    It doesn't seem to work for me though, only some parts of the mesh have collision, and what's even weirder is that it seems to differ based on the angle I am holding the phone. This is on an iPhone 11 btw.
     
  5. kshoukry

    kshoukry

    Joined:
    Nov 19, 2016
    Posts:
    3
    Never mind that. I just had to set the ball's collision to ContinuousDynamic.