# Unity: How do I get the coordinates of the vertices of a blender mesh?

I have gameobjects in my scene called icospheres that I have made in Blender, and I am trying to get the coordinates of their vertices. Below is an image of my scene; each triangle is a separate gameobject, blender mesh and is called an icosphere:

Here is the code I am using:

    var meshFilter = icosphere.GetComponent<MeshFilter>();
var vertices = meshFilter.mesh.vertices;
GameObject.Find("Fauna Manager").GetComponent<FaunaManager>().PlaceFauna(tree, vertices[0], icosphere);
GameObject.Find("Fauna Manager").GetComponent<FaunaManager>().PlaceFauna(tree, vertices[1], icosphere);
GameObject.Find("Fauna Manager").GetComponent<FaunaManager>().PlaceFauna(tree, vertices[2], icosphere);


The bottom 3 lines of code call a function that should in theory place another gameobject on top of the 3 coordinates that have been calculated above, however this does not happen. The tree-placing functions work completely and have been tested so the problem is definitely with the coordinates. I printed out the coordinates and the length of the array that holds them. The array is of length 3 as it should be however the coordinates are completely off. The trees have been placed a long way away from the icosphere which means the coordinates are clearly wrong. Where have I gone wrong?

example of coordinates: -0.1, 0.0, -0.1
centre of icosphere for reference: -0.7431812, 0.4044746, -4.932096


Above you can see that the coordinates are well off

• Did you remember to take into account the position/scale/rotation of the mesh object? – DMGregory Jan 27 '19 at 18:54
• @DMGregory no I didn’t, how can I edit my code to include this? – Finn Williams Jan 27 '19 at 18:59

Vector3 worldPoint = icosphere.transform.TransformPoint(localPoint);

Alternatively, you can parent your trees to the mesh object and set their localPosition instead.