Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Camera zoom on bounds with dynamic size.

$
0
0
In our game, we have a cube that the scaling will change and a camera using the perspective projection mode. We need the camera to zoom the cube so that we always see it as much as possible in the screen. We are using the corners of the cube to verify if the camera sees all of the cube. So when it scales up, the camera zoom out and when it scales down, the camera zoom in. It's a little complicated because the cube can scale only on one axis making it disproportionate to the screen size. So we do a general zoom in until we stop seeing it completely or zoom out until we see it completely. The problem is that at the end of the zoom in, the cube is not 100% in the screen anymore. So There's a zoom out the next frame to see if the cube is bigger. At the end of a zoom out, the camera zoom in because it's updating to see if the cube is smaller. So we have that continuous zoom in and zoom out problem. I was wandering if there was an easy way to control the camera zoom to contain a bound so that it fills the screen depending of its changing size. One last thing, the camera cannot skip the zoom update because it is also moving and does not start with the right zoom. In other word, we need the zooming even if the bounds size does not change.

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>