I am trying to find all vertices within a certain radius around a center vertex. Then setting these vertices alpha to 0. I am currently using this code:
public void clearFog(Vector3 center, float radius)
{
colours = mesh.colors;
//find the point in local space
Vector3 localSpaceCenter = transform.InverseTransformPoint(center);
for(int index = 0; index < verts.Length; index ++)
{
float distance = Vector3.Distance(verts[index], localSpaceCenter);
//if vert is within the radius
if(distance < radius)
{
colours[index].a = 0;
}
}
mesh.colors = colours;
}
But i clearly don’t understand something here, distance is always returning values between 1 and around 1.006 ish… how can the distance of every vertex in the mesh be between 1 and 1.006 away from the center vertex? It makes trying to judge how large the radius should be very difficult. What am i doing wrong here?
Thanks in advance.