Tiled2Unity sizing for zero pixel warping

This question is half to do with tiled and half to do with unity… actually… I’d go as far to say as it’s really all down to Unity. But you guys are probably the best people to ask because I’m sure this issue must have come up before.

In fact… I have searched for answers but what I have found seems to talk about “scaling” the level, or “camera size”… but not hard reasoning on why what I’m doing doesn’t work… in a nutshell… I can’t find a way to stop my pixels warping.

Elements that I think come in to play:
Unity display window scaling
Camera "Size"
Pixels per unit on sprite elements
Level scale

My tiles are 16x16 so I did 1/16 to get 0.0625 as the scale… but please note I have also tried 0.625 and 1 aswell. As for camera size I have tried changing the value but to no avail, wherever it sits the pixels always warp even just a little bit. Is there a logical way to make sure all the sizing is correct so pixels don’t “bleed”?

I saw another post talking about setting the camera size to the screen height divided by 2… but that would be absolutely HUGE compared to the level size so I assumed that was incorrect. Please point me in the right direction guys I’ve obviously misunderstood something fundamental here haha!

Thanks in advance for any help!

Hi there. I don’t know what you mean by pixel warping so maybe a screenshot would help?

You shouldn’t have to scale your exported Tiled map into Unity. The most you should have to do is set the “Pixels Per Unit” box to the same value you use in Unity when importing sprites. This is just to make sure your sprites and maps are using the same units in your scene.

For the orthographic camera size setting you need to determine how much of the map you want visible on the screen at one time and then use the h/2 formula. For instance, if you were making an old fashioned NES game (256x224 pixels in most cases) then your camera size should be 112.

Sorry I meant some pixels look wider/taller/smaller than others all at the same time. Now I have imported the level which is 1600 tiles wide and using 16x16 tiles. It is scaled to 1, and the camera is 112, and I set the screen size to what you said as an example. But now it looks so far zoomed out you can’t see anything. I must be confused about something here :frowning:

Head over to this site and have a read: http://blog.evilwindowdog.com/post/147292156801/a-pixel-perfect-camera-for-unity
Apparently they have a (free) script that you can use to solve that exact problem.

I have not tried it myself, so I can’t say for sure. But if you try it out, maybe you could let us know.

Hi Craig. There must be some errant transform somewhere in the mix. If you send me your Unity project I can take a quick look at it. Just right-click on your Assets folder in Unity and select “Export Package …”

You can find my email address off my website: www.seanba.com

Best,
Sean

Hi Sean, I’ve sent an email :slight_smile: And thanks CandyCreep I’ll check that out

For others who may run into similar issues, here’s what I saw with Craig’s map:

  • He was using a unity:scale value of 0.625 in the properties of his map in Tiled
  • He exported with a “Pixels Per Unit” setting of 10 in Tiled2Unity

I recommend never using unity:scale. It’s a deprecated property from before “Pixels Per Unit” was added to Tiled2Unity.

For “Pixels Per Unit”, use matching values for your sprites (in Unity) and your maps (in Tiled2Unity)

For camera size, if you’re using a Pixels Per Unit value of 100 then you have to divide your camera size by 100. So, if your window is 256x224 then you take half your height (112) and divide it by 100 (final value: 1.12).

That should do it.

1 Like