Physics.CapsuleCast
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
void Update() {
RaycastHit hit;
CharacterController charContr = GetComponent<CharacterController>();
Vector3 p1 = transform.position + charContr.center + Vector3.up * -charContr.height * 0.5F;
Vector3 p2 = p1 + Vector3.up * charContr.height;
if (Physics.CapsuleCast(p1, p2, charContr.radius, transform.forward, out hit, 10))
distanceToObstacle = hit.distance;
}
}