# Get vertex num from UV Coordinates

Hi,

I almost finish my coordinates system, but I have a trouble, I want to get the Vertex Num from UV coordinates:

``````	public float GetHeights(float x, float z) {

//Get the mesh from the scene
GameObject plane = GameObject.Find("GameScripts").transform.FindChild("Chunk_"+Mathf.Round(x/planeSize)+","+Mathf.Round(z/planeSize)).gameObject;

// Get the planes vertices
Mesh mesh = plane.GetComponent<MeshFilter>().mesh;
Vector3[] vertices = mesh.vertices;

//Get the UV coordinates from the selected mesh
Vector3 vectorToSearch = plane.GetComponent<MeshFilter>().transform.InverseTransformPoint(new Vector3 (x, 0, z));

//Try to get the mesh that have those coordinates
int vertexNum = 0;

for(int i = 0; i < vertices.Length; i++) {

if(vertices_.x == (int)vectorToSearch.x && vertices*.z == (int)vectorToSearch.z) {*_
``````

* vertexNum = i;*
* break;*
* }*

* }*

* return vertices[vertexNum].y;*
* }*
I try to get with:
for(int i = 0; i < vertices.Length; i++) {

if(vertices_.x == (int)vectorToSearch.x && vertices*.z == (int)vectorToSearch.z) {
vertexNum = i;
break;
}*_

* }*
I check all the vertex and I compare it with the vector getted but I don’t know why I only get 0, if everything is correct…
What I’m doing wrong?
``````if( (int)vertices*.x == (int)vectorToSearch.x etc...*