|
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?
(comments are locked)
|
|
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 although i didnt use your solution i thank you..i managed to resolve the issue in an uncomplicated way and that was to look for object bounds, like this collider.bounds.size, that is the Vector3, then to look the highest value and to set the distance to that value. in that way i have smaller and bigger object to fill out the screen when zoomed in... thanks everybody!
Jun 22 '10 at 10:18 AM
pretender
(comments are locked)
|
|
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.
(comments are locked)
|
