You will need a form of tracing. What kind to choose will depend on the object you’re tracing against. Here’s a sphere trace:
This fires a beam from the camera as wide as the object’s mesh, if the beam intersects with anything blocking Visibility, we can detect that.
I’m trying to find the best view of an actor on the screen. If there is a tree on the level and it’s current covering up the actor, I would like the camera to rotate around the tree. Rotation is easy, but I don’t know how to detect if something is in the way of the actor from a visibility standpoint.
If the target actor does not fit into a sphere neatly enough, a sphere trace could end up inaccurate; in that case you could box trace instead:
This projects a rotated box instead:
This is not a complete setup, more of a proof of concept. Certain aspect are simplified here and assumptions were made. But that’s the gist.
Hope it helps.