Seanba / Tiled2Unity

Export Tiled Map Editor (TMX) files into Unity
Other
497 stars 120 forks source link

Y position of tile changes with height of tile #105

Closed Crosscat closed 7 years ago

Crosscat commented 7 years ago

Having an issue with importing Tiled maps. Here is an example:

image

The one on the left is how it appears in Tiled, the one on the right is how it appears in Unity (and the Tiled2Unity previewer)

The ground tile is 32x32 and displays correctly, and the tree tile is 32x42. If I make the tree tile size 32x32 (cutting off the bottom of the tree), its y coordinate is then correct, but stretching it any amount pushes its position up (and decreasing its height it pushes it down). Changing the width has no effect.

This was working fine at some point previously, but even reverting back to older versions of both Tiled and Tiled2Unity seems to have no effect. This happens in both orthographic and isometric.

Here is the TMX:

<?xml version="1.0" encoding="UTF-8"?>
<map version="2017.05.26" orientation="isometric" renderorder="left-up" width="1" height="1" tilewidth="32" tileheight="26" nextobjectid="1">
 <tileset firstgid="1" name="GrassTiles" tilewidth="32" tileheight="32" tilecount="16" columns="8">
  <image source="../Textures/GrassTiles.png" width="256" height="64"/>
 </tileset>
 <tileset firstgid="17" name="Trees" tilewidth="32" tileheight="42" tilecount="1" columns="1">
  <image source="../Textures/Trees.png" width="33" height="42"/>
 </tileset>
 <layer name="Ground" width="1" height="1">
  <data encoding="csv">
10
</data>
 </layer>
 <layer name="Trees" width="1" height="1">
  <data encoding="csv">
17
</data>
 </layer>
</map>

Any idea what would cause this?

Seanba commented 7 years ago

It looks like you've found a bug. I suspect it's because your tiles have different heights and widths. Do you mind sending me the GrassTiles.png and Trees.png files? I'm sure I can put in a fix for this.

Crosscat commented 7 years ago

Here, updated with simpler tmx and just single tiles per file:

image image

<?xml version="1.0" encoding="UTF-8"?>
<map version="2017.05.26" orientation="isometric" renderorder="left-up" width="1" height="1" tilewidth="32" tileheight="26" nextobjectid="1">
 <tileset firstgid="1" name="Trees" tilewidth="32" tileheight="42" tilecount="1" columns="1">
  <image source="../Textures/Trees.png" width="32" height="42"/>
 </tileset>
 <tileset firstgid="2" name="GrassTile" tilewidth="32" tileheight="32" tilecount="1" columns="1">
  <image source="../Textures/GrassTile.png" width="32" height="32"/>
 </tileset>
 <layer name="Ground" width="1" height="1">
  <data encoding="csv">
2
</data>
 </layer>
 <layer name="Trees" width="1" height="1">
  <data encoding="csv">
1
</data>
 </layer>
</map>
Seanba commented 7 years ago

I think I may have a fix. Give me a bit to publish.

Seanba commented 7 years ago

Tiled2Unity version 1.0.12.1 contains a fix for this (and some other stuff too). Don't forget to update your scripts in your Unity project while upgrading. Thanks for the bug report!

image

Crosscat commented 7 years ago

That seems to have done the trick. Thanks a lot for the quick response!

Out of curiosity, what is the plan for releasing the source code? I notice the latest github commit here is a few months old. Being able to make a few personal changes to the import process would make certain tasks easier on my end.

Edit: I actually might be able to accomplish what I need by just editing the scripts in Unity. In which case I do not think I have any more issues. :)

Seanba commented 7 years ago

Great to hear that worked. I updated the Github source. Because of legacy reasons (the original Tiled2Unity source is actually stored elsewhere in a SVN repository) that often lags behind. I'll try better at keeping that up-to-date.