Is there a way to make a Character Controller stop instead of move over obstacles??

I’m making a flying camera in a 3rd person game. I want the camera to stop moving when it hits an obstacle. I tried various raycast/spherecast techniques but none of them worked right.

So, I attached a Character Controller to the camera. It works pretty well, but it wants to climb over obstacles. I tried making the Slope Limit 0, but it still climbs over some stuff, or slides against the floor.

Is there any way to make the Character Controller come to a dead stop when it hits something? Perhaps by using the OnControllerColliderHit event/callback?

I’ve used something like this:

var stopDead = false;
function MoveOrStop(dir: Vector3)
    stopDead = false;
    var oldPos = transform.position;
    if (stopDead)
        transform.position = oldPos;
function OnControllerColliderHit (hit : ControllerColliderHit)
    if (hit is something that should stop you)
        stopDead = true;