I'm trying to make a clone of the trail/line renderer with the difference that everything is perfectly flat, i.e. the faces are not designed to face the camera. I'm using two raycasts to get the position of the edges of where I want those faces but now I'm struggling to generate the mesh...I've gone through the mesh docs but I don't really understand it. Could someone help me do this?
Here is my code so far:
public Transform[] probes;
public float probeDistance;
public Vector3[] newVertices;
public Vector2[] newUV;
public int[] newTriangles;
void Update () {
//Generating the mesh
Mesh mesh = new Mesh();
GetComponent<MeshFilter>().mesh = mesh;
mesh.vertices = newVertices;
mesh.uv = newUV;
mesh.triangles = newTriangles;
//Defining the rays
Ray l_ray = new Ray(probes[0].position, -probes[0].forward * probeDistance);
Ray r_ray = new Ray(probes[1].position, -probes[1].forward * probeDistance);
RaycastHit l_hit;
RaycastHit r_hit;
Debug.DrawRay(probes[0].position, -probes[0].forward * probeDistance, Color.blue);
Debug.DrawRay(probes[1].position, -probes[1].forward * probeDistance, Color.red);
//Getting the position of the left ray point
if(Physics.Raycast(l_ray, out l_hit)){
print (l_hit.point);
}
//Getting the position of the right ray point
if(Physics.Raycast(r_ray, out r_hit)){
print (r_hit.point);
}
}