Can anyone point me into the right direction of how to get the vertices of a specific face of a mesh, or another way of getting the corner positions. Thanks.
If you have the index of the face, then use Mesh.triangles to get the indices into the Mesh.vertices array.
I recently found a good way of doing this for cubes (sides are all the same).
Script Reference: RaycastHit.triangleIndex
Transform hitTransform = hit.collider.transform;
int t = hit.triangleIndex * 3;
p0 = vertices[triangles[t]];
p1 = vertices[triangles[t+1]];
p2 = vertices[triangles[t+2]];
if (p1.x != p0.x) {
p3 = p2;
p3.x = p0.x;
}
if (p1.y != p0.y) {
p3 = p2;
p3.y = p0.y;
}
if (p1.z != p0.z) {
p3 = p2;
p3.z = p0.z;
}
p0 = hitTransform.TransformPoint(p0);
p1 = hitTransform.TransformPoint(p1);
p2 = hitTransform.TransformPoint(p2);
p3 = hitTransform.TransformPoint(p3);
Hope this helps anyone who has been struggling to figure this out