Camera with target object displacement

Hello,

I’m struggling quite a bit with this math issue. I have a camera orbiting and facing an actor at a given but random distance and angle. For example -45 degrees pitch (looking down on the actor) with some units of distance.
Further, I have divided my viewport/screen into a grid of square size, for example 5x5, with a selected cell given by 0 indexed values (i.e. 0, 0 being top left). What I want to achieve, is to displace the actor in view such that it appears in the center of a given cell on the screen.

I still want both the camera and actor location to remain the same, I just want a rotational offset for the camera, such that the actor no longer appears in the center, but at the center point of the grid cell.

I have already calculated normalized coordinates for the screen grid, ranging from -1 to 1, given the grid indices.

My initial approach was to pan the camera to the totally opposite screen grid cell of the target cell, and hoped that would displace the actor into the target cell. However, there are some more math involved, making it only work in some cases. For example, in one case, panning the camera into top right would only have the actor appear too close to the middle and way too far down in the screen.

Any help would be greatly appreciated!

I suppose the camera distance and angle are calculated based on actor size / other factors, so that the actor doesn’t leave it’s grid space? is there any chance a camera would not be able to make a shot (level collision etc.)? Is the camera in perspective or ortographic mode?

Note I don’t have a direct solution but such factors that require solving pop up in my mind.

Not sure how you set up the viewport to divide like that. Does it use the UI? (a widget panel with grid) that you want to display camera shots on? Or can you show me something similar to your idea?

https://www.youtube.com/watch?v=qMJRqwgEyqo

Basically for non gameplay purposes, and for ease of implementation, it sounds like a UI implementation.