- Home /
 
 
               Question by 
               zacharyaghaizu · Jan 04, 2021 at 04:11 PM · 
                linerenderermeshcollidermeshfilterline rendererline drawing  
              
 
              Convert Line Render to 3d Mesh with Collider
I have looked around and haven't found a working answer, so your help would be appreciated!
Currently with this script, the line creates a blank mesh filter. The closest I got to was having offset simple block that does not follow the shape mesh at all. I need this in order to be able to have the shapes drawn with the line trigger sounds on collision
GameObject go = new GameObject($"LineRenderer");
 GameObject go = new GameObject($"LineRenderer");
 
 goLineRenderer = go.AddComponent<LineRenderer>();
           //zac
        
           
    
         Mesh lineBakedMesh = new Mesh(); //Create a new Mesh (Empty at the moment)
     go.AddComponent<MeshFilter>();   
   go.GetComponent<MeshFilter>().mesh = lineBakedMesh;
        goLineRenderer.BakeMesh(lineBakedMesh,Camera.main, true); //Bake the line mesh to our mesh variable
         go.AddComponent<MeshCollider>().sharedMesh = lineBakedMesh; //Set the baked mesh to the MeshCollider
         go.GetComponent<MeshCollider>().convex = true; //You need it convex if the mesh have any kind of holes
 
 
              
               Comment
              
 
               
              Your answer