Automatically find edge for Target Matching

I use target matching to allow my character hang on objects. currently i have hand targets placed everywhere, but i wan’t it to be automatic. what will be the easiest way to find nearest edge on any mesh (not just for cubes).

You can access the vertices and triangles from the Mesh object. There’s an edge between any two vertices that share the same triangle ID. You can then work out the closest point on each of those edges as described here, and that’s the nearest edge point.