HELP Camera mechanic.

I’m stuck trying to solve this.
I try to make the camera that follows the player change its position based on the player’s position.
I mean, if the player turns an object, the spring arm changes its rotation, so that he can continue to see the player.
Another mechanic that I try to achieve is when the player enters an area where the camera no longer sees the player. For example, when you enter a tunnel, the blocks that cover the player’s camera become invisible so that the camera maintains its position and can continue to see the player.
I hope you can help me. ty!