Help with a simple function.

I need a function that takes two points as arguments and returns true if the line segment connecting them passes through a solid object, and otherwise returns false. How would I implement this?

there is already a function for that. you can use it like this:

return Physics.Linecast(point1.position, point2.position);

or read more here: http://unity3d.com/support/documentation/ScriptReference/Physics.Linecast.html