If it should only hit with left,up,right,down use Raycasts.Your code will look lile that
public float[] CheckCollisions() {
Raycast hit;
float[] collisions = new float[4];
if (Physics.Raycast(transform.position, transform.Vector3.Up, 100.0f, out hit))
collsisions[0] = hit.transform.position - transform.position;
else
collsisions[0] = Float.NaN;
//other directions
return collissions;
}
This isn't the most beautiful way, make a Vector3 array with all directions you wanna check and then iterate through (and check current Vector for hit)
Sorry for mistakes, wrote this with cellphone.