unity3d - 2D camera positioning in Unity -
i'm writing 2d game in unity , force orthogonal camera's view frustum altered on right-hand side according device's aspect ratio, left/bottom being set 0,0
i.e.: i'd bounds of camera's y frustum to 0 @ bottom , 10 @ top. easy , i've done moving camera's position 5 , setting camera size 5 (i'm presuming has worked). (also, there's no real reason why i've gone 10, seems round number...)
when scene starts i'd move camera's x frustum left 0 , right whatever aspect ratio demands: somewhere between 4:3 , 16:9 depending on device. pretty mean setting camera's x translation presume, i'm touch lost on how aspect ratio, , calculate should be?
...and here's answer:
vector3 pos = new vector3(5.0f * camera.main.aspect, 5.0f, -10.0f); camera.main.gameobject.transform.position = pos;
which popped main.cs script, under start() function. 5.0f half height of 2d camera'a othrogonalsize (as mentioned in question above), , -10.0f default z-position main camera in 2d game.
Comments
Post a Comment