#How to position the camera to include certain points on screen.
1 messages · Page 1 of 1 (latest)
Some more information would be good like, is it 2d or 3d, perspective or orthographic? But in the end, you would calculate the fartherst top right bottom and left objects, get the distance relative to your screen resolution and then move the camera back for that amount of distance combined. Rotation would look at the average least distance between all tracked objects.
Ah mb,
It's 3d, perspective, the camera isn't pitching or yawing but it is rolling along its forward axis.
Obligatory: use Cinemachine, it has the feature built in. No maths required
Looking to learn it for myself, do you think the code for it is readable to study it?
If you just want to learn it, I would just start coding and see, how far I get. When getting stuck , you could read the cinemachine code, if it is readable at all. But a little testing and trying out if you do not have any time pressure is always good.
The math is pretty simple. You're basically just calculating a bounding box followed by a little trigonometry with your fov. But you have to decide if you want to dolly or zoom to fit.
But yeah Cinemachine target group does this automatically.
Oh yeah I guess it is pretty simple