I’m trying to get the vertices and triangles arrays of a mesh at start, this is done for the car AI control in my racing games.
Now I want to share part of this with the community and I’m making a project with basic car physics and basic AI, but …
Why this give me an error?
private var trackVertices;
private var trackTriangles;
function Start () {
var mesh : Mesh = GetComponent(MeshFilter).sharedMesh;
trackVertices = mesh.vertices;
trackTriangles = mesh.triangles;
print(trackVertices.length);
}
but this one not?:
function Start () {
var mesh : Mesh = GetComponent(MeshFilter).sharedMesh;
var trackVertices = mesh.vertices;
var trackTriangles = mesh.triangles;
print(trackVertices.length);
}
The problem is I want to get the vertices and triangles arrays to another script as variables, and in the first case it won’t work and in the second case I cannot get it externally.
The fun part is I made a dozen setups with the “wrong code” (the first one) and it worked fine, but when I simplified the scripts it doesn’t.
Thank you