Ai navigation around obstacles?

I am in the brainstorming stages of creating a script that helps an NPC get around obstacles. I was wondering if there is a way that, with a Raycast or something, I can get the position of the ends of the obstacle in order to find the shortest or quickest way around.

If you have the pro version of Unity, then you can use the NavMesh Agent:

NavMesh Agent documentation

Otherwise, using a A* algorithm is widely used and works really well.
There are lots of tutorials on the net and here on UnityAnswers about A* and how it works.

Good luck!

If you want to develop your own system for learning without any advanced A*. You could develop something with Raycast, but there s a high chance that your guy will look a little jittery.

One way I would tell, try to reproduce the blind man cane like this:

Vector3 vec = new Vector3(_transform.forward.x+(float)Mathf.Sin (Time.time),_transform.forward.y,_transform.forward.z);
Debug.DrawRay(_transform.position,vec);

Add this to your guy and you will see a little ray sweeping in front of him. Now same process with a raycast.

    RaycastHit hit;
    Vector3 vec = new Vector3(_transform.forward.x+(float)Mathf.Sin (Time.time),_transform.forward.y,_transform.forward.z);
    if (Physics.Raycast(transform.position, vec, out hit)){
        Vector3 contact = hit.point - _transform.position;
        Vector3 cross = Vector3.Cross(contact, _transform.forward);
        if (cross.y < 0) //Hit on the right rotate to the left
        else //invert
    }

This is simplified for you to start. But it means that as long as your “cane” hits something it gets the object to rotate opposite until your cane does not hit anything.
That would have to be tried though as I am just writing this by logic and my logic sometimes…

Please have a look on unitygems.com and there you will find the tutorials on a*pathfinding have a look …Enjoy