Q:

Most Efficient Way to Check Player Distance from a Line?

I need to get the player's distance from a line (or the outside edges of an Gameobject, if that's easier) throughout their time in the game. I need the code to be fairly simple because I'm a novice (though if it's thoroughly explained, I can implement more complex solutions). 
Is there an optimal way to do this that doesn't involve resorting to using the full formula for a point to a line? Because I think I might have some trouble implementing that in unity's system (translating to/from coordinate systems, maybe). 
Thanks!

A:

First of all, because I don't have a compiler right now:
List<GameObject[]> gList=new List<>();//this may have some problem, try initiating in your way

GameObject[] line1=new GameObject{g1,g2,g3}; //g-n is just some gameobject
GameObject[] line2=new GameObject{g4,g5,g6,g7};

gList.add(line1);
gList.add(line2);

GameObject[] targeted=null;

foreach(GameObject[] x in gList)
{
Vector3 f=x[0].transform.position;
Vector3 l=x[x.Length-1].transform.position;

//calculate distance as you know the math
//if(condition) //depending upon min or max or what-ever
    //targeted=x;

}

Maybe this will help

