Unity world space

Getting my head around unity world space and how it relates to screen size.

Unity Unit

The unit of measurement in unity. It is good practice to match 1 unit to 1 meter. Default physics and lighting systems are all tuned to this scale.
Tile mapKeep a scale of 1 tile = 1 unit, just for the sake of simplicity.

Camera

How much of your game is visible depends on:

  • Camera size
  • Aspect ratio of your platform’s resolution (e.g. monitor, phone, etc) 

ExampleIf you want your game’s viewport to include about 10m of your scene vertically (for a 2D game).
Camera size: 5 unitsMy scale: 1 unit = 1 meter

Pixels per Unit (PPU)

This is a property of a unity Sprite. Specifies how many pixels from your Sprite fit into a unit in the scene when the GameObject is scaled 1,1,1. 

Setting the right combinations

If you want to make sure all the sprites are the right size relative to each other and the same ‘sharpness’ no matter how far in/out you are zoomed, you should adhere to a consistent unit of measurement for your world. 
If you want to make sure images are sharp on a particular resolution, you need to make sure you have the right combination of these:

  • Object height
  • PPU
  • Camera size.

Example

  • Character height of 1.6m
  • Camera view height of 10m
  • Supporting resolution 2436 x 1125px

Required PPU (for this resolution) = 1125 / 10 = 112.5

Responsive game sizes

If you want to make a responsive game that works for multiple resolutions, you’ll have to decide on how you want to deal with the screen size changes. Say, if you have a bigger screen:

  • Do you see more of the world? 
    • Does this significantly change the game play?
  • Or is everything just enlarged? 
    • If everything is enlarged, then you have to make sure the resolution of your images is high enough to support your largest supported device.

To be continued…

Leave a Reply

Your email address will not be published. Required fields are marked *