Oct 01 2014

pixel perfect tiles in unity

I was wrestling a bit with how to get my tiles 1:1-scale. Turns out this is the way to go:

  • Set camera to orthographic (2d), and set the size to screen height/2. Since I optimize for PS Vita screen (960×544) that’s 272.

  • Now the tiles are super tiny. That’s because I created the vertexes with 1 unit as spacing. My tiles are 64×64 so I can either re-write all my vertexes (multiply them with 64). OR we can keep the 1-unit vertexes and divide the camera size (27264 = 4.25)

Will probably cause some problem when I have to move my sprites by 164 per pixel… That’s future Tommy’s problem though =)
Oh, and if you have a dynamic size of your screen you can use Screen.height;

Edit (2016-12-14):
here is a good blog post from Unity about pixel perfect 2d in Unity: