Hi, im able to create a mesh on a line renderer through .BakeMesh the issue im having is that the mesh is created in local space, I need it in world space to match the line renderer. Heres my code:
lineChild = Instantiate(linePrefab, lineManager.startObject.gameObject.transform);
// Create a new LineRenderer component
lineRenderer = lineChild.GetComponent<LineRenderer>();
MeshCollider meshCollider = lineChild.AddComponent<MeshCollider>();
lineRenderer.material = lineMateral;
lineRenderer.startWidth = 0.04f; // Set the starting width of the line
lineRenderer.endWidth = 0.02f; // Set the ending width of the line
// Set the start and end points of the line renderer
lineRenderer.SetPositions(new Vector3[] { lineManager.startObject.transform.position, lineManager.endObject.transform.position });
Mesh mesh = new Mesh();
lineRenderer.BakeMesh(mesh, true);
meshCollider.sharedMesh = mesh;
Vector3[] vertices = mesh.vertices;
for (int i = 0; i < vertices.Length; i++)
{
vertices _= lineRenderer.transform.TransformPoint(vertices*);*_
}
mesh.vertices = vertices;
mesh.RecalculateBounds();
meshCollider.sharedMesh = mesh;
Debug.Log(“Line Added”);
lineManager.lineIsActive = false;
lineManager.startObject = null;
lineManager.endObject = null;
}
}
I’ve tried fixing it using .TransformPoint but that didn’t work, anyone got any ideas?
Heres a pick of where the mesh is being generated. [206158-mesh-in-local.jpg|206158]_
_