Camera inside Tunnel

Hi…,
Please, i need some guides to do that:
if there is player move inside tunnel and there is a camera follow this player, How can make camera don’t go through tunnel walls ?

You would need to check collision somehow and adjust the camera. Take a look at the wow cam scripts here in the forum to see some examples of how they use raycast to reposition the cam.

i used this code but i don’t see any effect …

var wall : GameObject;

function Update () {
    var ray : Ray = Ray(wall.Transform.Position, wall.Transform.Position - transform.Position);
    var hit : RaycastHit;
    if(Physics.Raycast(ray, hit)){
        Camera.main.transform.position = ray.GetPoint(hit.distance-1);
    }
}