I have two objects. One of them is parent, another one is its child. I want to get vertex position of parent object.
I use the following script, which is assigned to child object, to get the position of parent first vertex in axis X.
Vector3[] vertices = transform.parent.GetComponent<MeshFilter>().mesh.vertices;
var gPos = transform.TransformPoint(vertices[0]);
print("Parent vertex at " + gPos.x);
Another script is assigned to parent and performs the same function
Vector3[] vertices = GetComponent<MeshFilter>().mesh.vertices;
var gPos = transform.TransformPoint(vertices[0]);
print("Parent vertex at " + gPos.x);
But issue is that i have different numbers. For example, first script shows -5, second one -3.
I know that this is somehow related to the position of child object relative to its parent, because the chilld object location in axis X is 2. It pluses this number and i get those results.
Can somebody help me to understand why i get different positions.
Thank you.