Question About relationship between Unity World Units and other terms?

I am still confused about the Unity World Units and the Play Space? What is the exact relationship between camera size,height,width,aspect ratio? I know the relationship between size and height i.e height of camera = 2*size. But what’s the relation between height,width and aspect ratio? Is there a mathematical formula to calculate the exact width in Unity World Units?

And, I am also confused about the Pixel Per Unit value of the sprite. Rick explained that a sprite of 128*128 pixels will take up exactly 1 unit in the Unity World space when its Pixel Per Unit value is set to 128 Pixels per unit. And, for the same sprite if its changed to 64 Pixel Per Unit it takes up 2 units in the same Unity World Space. But, how can we calculate the exact Pixel Per Unit that takes 1 Unity World space for the paddle which has a resolution of 256 * 64 pixels?

Also for the background image we divided its 1080 pixels height by the camera height of 12 units which indeed gave us 90 Pixel Per Unit value. So, 90 pixel per unit in this background image sprite fills up the whole size of camera. So, is this mathematical equation true for all the sprites like if we divide the block spirte 128 pixels height by 12 then the resulting 10.666666667 pixel per unit value if set should fill up the whole camera? And, what about the objects like paddle with uneven resolution?

Hi Wilcy,

World Units (WU) are “inside” the entire World Space, which is way bigger than the viewport of our camera. In Block Breaker, the viewport of the camera also defines the game space because the player cannot move elsewhere in the World Space.

The height of our camera is static. It is defined by its size. As you said: height of the viewport = 2 * size`.

The width is dynamic and adjusts itself to the aspect ratio of our game screen. In the Unity Editor, the game screen is defined in the Game window. You can either select an aspect ratio or a resolution. In the final build, the game screen ist defined in the Player Settings > Resolution options. In fullscreen mode, the game screen would be limited by the edges of your monitor.

The PPU value refers to the width in pixels of the concerning texture/sprite.

If your paddle has got a width of 256 pixels and you set its Pixels Per Unit (PPU) value to 256, the paddle will be “squeezed” into 1 WU if you drag it into the game screen.

What’s the height of your background image in pixels?

1 Like

Hello Nina,

I am actually using the exact background image as Rick did, so its height should be 1080p. So, its the width that defines the PPU with the value 256 which will be 1 WU for the paddle like you mentioned then what does the height of the paddle do which is 64 pixels? What if I want the paddle with resolution 256*64 pixels to cover the whole viewport just like we did with the background image? What PPU should the paddle have and how can I calculate it? I have camera size at 6 just like in the video. Also the aspect ratio is 4:3. Everything else too same as in the video.

How wide is your game screen in the viewport? 16 World Units (WU)? Count the grid tiles in the background. If your paddle is supposed to cover the entire width, set the PPU to 256 / x where x is the number of WU you counted.

What width does your background image have?

1 Like

The width of the background image is 1440 Pixels. Yes, the width of the game screen in the viewport is 16 WU. So, if I want the paddle to cover the entire width then 256/16 would be 16 PPU. So, if I want a particular spirte to cover the entire viewport just like the background image with both height and width then I would need a sprite with the same aspect ratio as the viewport otherwise it will just cover either the entire width or the entire height of the viewport only right? Or Am am I still missing something?

That’s right. Unity does not distort the sprite but keeps it as it is. For this reason, the PPU affects the width of the rendered sprite only, and the height automatically adjusts itself according to the aspect ratio of the original sprite.


Regarding the background image:
1440 / 16 = 90 (PPU)

What’s its height? If its resolution is 1440 x 1080, its aspect ratio is 4:3.

Since our game screen is 16 WU wide and we do not know the height (h) in WU yet, we calculate:

4 : 3 = 16 : h
h = 16 * 1/4 * 3 = 4 * 3 = 12

Our screen is 12 WU high if it is 16 WU wide and has got an aspect ratio of 4:3. Since our background image has got the same aspect ratio, its height in WU is also 12 if its width in WU is 16.


Assuming our background image had a resolution of 1440 x 810. That would be an aspect ratio of 16:9. Our game screen still has got an aspect ratio of 4:3 (16 x 12 WU). If we wanted to cover the entire height with our background image, we would have to make Unity crop a bit of the width (w) in the game screen area.

4 : 3 = 16 : 12
16 : 9 = w : 12
w = 16/9 * 12 = 21.3333

To make our 16:9 background image fit the height of our 4:3 game screen, we have to set its PPU to 1440 / 21.3333 = 67.5.

That should work unless I did something wrong.

Hey, I think I got the answer to my question. Thank you so much for spending your time to explain it so perfectly.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms