Search Unity

Question Mesh Renderer seems to not fit the Edge perfectly

Discussion in 'General Graphics' started by SeedorfN, Jan 23, 2021.

  1. SeedorfN

    SeedorfN

    Joined:
    Jan 23, 2021
    Posts:
    2
    Hello,
    We are currently trying to lay mesh colliders onto our edges as shown in the pictures. The problem is that the meshes sometimes seem to be 2D instead of 3D (shown in picture 2 and 3), which makes them unselectable from certain camera-angles. Sometimes the meshes even seem to disappear through some parts of the Edge(Picture 1).
    Turning convex on for the colliders makes them way easier to select, but we dont really want to do that because that makes it realy unclear which edge you are selecting right now.
    We are creating our meshes through bakeMesh from our previously created Edges as shown below:

      
    LineRenderer lineRenderer = gameEdge.GetComponent<LineRenderer>();
    MeshCollider meshCollider = gameEdge.AddComponent<MeshCollider>();

    Mesh mesh = new Mesh();
    lineRenderer.BakeMesh(mesh, Camera.main, false);
    meshCollider.sharedMesh = mesh;
    meshCollider.convex = false;
     

    Attached Files:

  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,336
    Line renderers are flat strips of geometry that are oriented to face the camera. The meshes line renderers create by baking them to a mesh are not going to be useable collision geometry. You'll want to look at generating some kind of tube mesh to use for collision.
     
    koschke likes this.
  3. SeedorfN

    SeedorfN

    Joined:
    Jan 23, 2021
    Posts:
    2