How to detect stuffs between character and following camera?

I have a character and a camera behind him, also what this camera is looking at is what the game player is looking at. I tried “smoothfollow” script, but when the character is very close to a building and turns around, the following camera is then inside of the building, and loses the sight of the character (there is a wall between the character and the camera). So if there is a way to detect whether something is between the character and the following camera, I can adjust the position of the camera and avoid above situation.

Any clue?

Thanks.

Cast a ray (Raycast) from your camera to your player, if the ray hits something you’ll know about it and you can respond as necessary or desired.

Thank you very much, HiggB, I will take a try. :smile:

We use something alike in Lies and Seductions (zooming closer if a wall is between the camera and PC). You can get the source and take a look ( http://mlab.taik.fi/~plankosk/blog/?p=308, CameraController.cs)