Seanba / Tiled2Unity

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

[Question] How do I do Z-Ordering? #129

Open IOExceptional opened 7 years ago

IOExceptional commented 7 years ago

Hey,

How do I do z-ordering, so that my player appears on top of a wall above, but behind a wall that's below?

This is trivial for many sprites (of course) but with a mesh, it appears to be incredibly difficult

matthuston commented 7 years ago

When you export using Tiled2Unity, you need to check Depthbuffer and then any Sprites you use need to have the Tiled2Unity SpriteDepthInMap material. The SpriteDepthInMap will use your Tiled map file to calculate it's z-position in relation your layers, for instance walls above and below and your floor layer.

zhangquxi commented 6 years ago

I also have the same problem! My game is 2D and My question is below: On the map there is a wall,I want my player appears on top of the wall when in front of the tree and behind the wall when player move behind to the wall tile. right(front): image error(behind): image I want to fix it by z-ordering,by caculating the y position value.The y is begger(means it further), the z value is bigger.So camare will do this. But I find the Object import by Tiled2Unity,the transform.position is all (0,0,0),so I can't even get any position.Here is the picture: image Why the position is (0,0,0)?In c#,I use transform.position and transform.localPosition,the result is still (0,0,0). Who can help me, thank you a lot!