Smooth Camara Follow Script

Hi
I have a problem with camera follow script, because when camera is following my character I don’t want camera view go outside my room. How to do this?
I was trying two things.
First I was playing with offset but I need different offset on left side room and different for right side room.
Second I was trying with two colliders, and start/stop camera follow script. It’s almost fine but only when player is newer going back.
Can you help me with this ? I totally stuck.

Well I done it. I don’t know if it’s the best solution but it works. I just simply starting and stoping Following script according to character x position .
When the character position x is greater then something stop follow.
This solution doesn’t work if my another rooms ( levels) will be in different size :frowning: but maybe I will try to play with room and character position together.

I think you can create raycast from camera to character, and check if this line hit something like the wall, if it hit the wall then send a stop to follow script.
Or you could just put a box collider to the camera, and ontriggerEnter (wall object) stop following, ontriggerExit continue to follow.

Best of luck