Nice little piece of code found here

public static float DistanceToLine(Ray ray, Vector3 point)
{
    return Vector3.Cross(ray.direction, point - ray.origin).magnitude;
}

 

Advertisements