Allow terrain in between the camera and actor, but not allow the camera to clip through terrain.

Not sure if there’s any simple solution for this.

I’m working on a top down game with a camera attached to a boom/spring arm component. What I want to achieve is that when shallow terrain comes in between the player and the camera, that it can pass through the camera boom. However, I also do not want the camera itself to clip through terrain that is tall enough. I can’t seem to figure out how to accomplish this since it seems that either the camera has collisions and zooms in to the point where the boom is intersected, or doesn’t have any at all and will clip through terrain.

I’ve made a simple sketch to clarify it a bit.

The top situation is when the collisions are enabled. If a small hill passes in between the camera and actor, the camera will locate itself against that hill.

The middle situation is when collisions are disabled. The camera can now clip through terrain like it’s not there.

The bottom situation is what I try to achieve. Anything in between the camera and actor can pass. Anything the camera itself hits, will make it close in on the actor.

Is there a way to achieve this? The camera is on a fixed distance by the way.