Make camera rotate around an object while keeping entire area visible
I attached my camera to an empty gameobject that is positioned at 0/0/0. If i rotate the object the camera will stay focused on the object and rotate around the area. This works perfectly.
The issue that im facing now is that my ares isnt a circle but a rectangle. This means that at certain angles corners of the area are cut off which is not good:
The solution to this problem should be really simple. The game object would have to move depending on the rotation of the camera so that the entire area stays visible (The sphere is just a representation of the gameobjects position) :
I could hard code it but with 360 degrees it would be a nightmare and probably a lagging mess.
Is there a formula or some better solution for my problem? Thanks in advance.