Hi people, I’m trying to script something that’s way over my capacities, therefor I need to procedurally generate a mesh. The only problem I have is that I really don’t get it how triangles are to be scripted, since the documentation seems a bit unclear about this.
When I got five vertices, let’s call them pt0 - pt4, then how am i supposed to draw a poly between pt0, pt1, pt2 and another one between pt2, pt3, pt4?
This is what I’ve tried so far:
var pt : Vector3[]; //This including the five points pt0-pt4.
function Update () {
mesh.vertices = pt;
mesh.triangles = [0, 1, 2];
mesh.triangles = [2, 3, 4];
}
I don’t know why, but I’m not able to draw the polys where I want them. Sometimes, they seem to be drawn randomly or without a logical order. Can anyone tell me what’s wrong with this? Or how Triangles are to be created procedurally?