FMath::PointDistToSegment

Returns distance from a point to the closest point on a segment.