# using objects bounds to zoom in object

hi everybody! i am trying to figure out how to calculate the zoom of the object based on its bounds so it fills out the screen completly.i have a lot of objects in the scene and all of them are different sizes, when i click on some of them, the zoom in, the smaller ones dont get zoomed in enough. i have a constant zoom factor which i would like to calculate based on objects bounds. how should i do this? does screen width and height plays any role here?

Screen width/height shouldn't play a role. What should play a role is the camera's FOV (and possibly near/far clip planes). The FOV in Unity is vertical.

I don't know the math offhand, but you could figure out for a given height how far away from the camera you need to be for it. According to this thread, it's simply using the tangent of the FOV.

Alternatively, you might be able to whip up a solution by calculating the camera frustum planes and moving forward until they are no longer in bounds

You can give them all tags, like size1, size2, size3, raycast and check the tags, if it's size1 so it'll zoom * 2, size2 * 3.