Answer the question
In order to leave comments, you need to log in
Zoom cameras in a 2D game?
I want to zoom in and out on a background in a 2D game. The camera in orthogonal mode is aimed at the background sprite (using the 2d toolkit), sprite in original size without scaling. The minimum zoom value will be the size of the camera, at which the sprite will fill the entire screen with cropping in height. Maximum - a certain hardcode or coefficient as a percentage of the minimum.
I can't figure out how to calculate the size value for the minimum zoom, while I know the screen and background sizes.
Should the camera view port be changed for different screen aspect ratios?
Answer the question
In order to leave comments, you need to log in
I'll answer my own question.
minCameraSize = ((backSprite.renderer.bounds.size.x) / backCamera.aspect) / 2;
backCamera.orthographicSize = minCameraSize;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question