Vertex transformation - MissingFieldException error

I’m getting MissingFieldException: UnityEngine.Vector3.transform when trying to use
a script. I don’t know whats wrong with it and it’s frustating me.

    function Update () {
    var mesh : Mesh = GetComponent(MeshFilter).mesh;
    var vertices : Vector3[] = mesh.vertices;
    var normals : Vector3[] = mesh.normals;
    for (var i = 0; i < vertices.Length; i++)
    vertices_.transform.position = vertices*.transform.position + Vector3(0,Random.Range(-1,1),0);*_

mesh.vertices = vertices;
}
Can somebody help me ?

Vertices in a mesh are Vector3 objects. Vector3s don’t have a transform or a position. To move one you would do:

vertices *+=  Vector3(0,Random.Range(-1.0,1.0),0);*

Note that your original code had integers in the Random.Range(), so the code would only have returned values -1 and 0 (since the integer version of Random.Range() is exclusive of the final value passed). I changed it to use floats.

Only GameObjects do have transform, your vector array doesnt, as it is no GameObject.

vertices *+= Vector3(0,Random.Range(-1,1),0);*

This should work. But why? Because you are now using the vector’s values, instead of trying to access something that isn’t even there.
Cheers, WRZ
edit: oops, too slow :slight_smile: