One way to do it is to have different states of the camera. So on a script attached to the camera, you can have an enum or a set of different states. For the main movement following the player, you can have the camera position just match the player position with an offset. Or you use a velocity vector, for example derived from the distance to the player. Then for the room transitions, you can change to a different state, and on that state just move at a constant rate in the direction of the new room. Or you can use a tween or lerp, this would handle the math for you.