Hi, I’m currently trying to make a 2D isometric map for my game project in Unity. However the converter Tiled2Unity doesnt support isometric maps. My only option left is to create it in orthographic mode and then rotate it inside Unity. But being a complete newbie I have no idea how to do it, making a isometric map in orthographic mode that is.
You can’t really make an isometric map in orthographic mode, unless you know how to juggle your tiles around to make that work. For example, I believe the Starcraft I level editor essentially managed to produce an isometric looking map with an orthographic grid. Of course if you do it that way, you would not be rotating your map in Unity afterwards.
If you’re going to do it by rotating the map in Unity, then I guess you would either have flat tile textures that won’t look strange when rotated, or you could squeeze your isometric tiles into squares for usage in Tiled so that they will at least look as intended once rendered rotated in Unity.
Alternatively, did you try contacting @Seanba about adding support for isometric maps to Tiled2Unity? That would obviously be the most comfortable approach.
I have some support for Isometric maps in Unity with UTiled. It is source
only, and not in the downloadable versions: https://bitbucket.org/vinull/utiled
You can use this or take the code you want for your own solution. You will
need to think though how you indend to use the map and setup your layers
accordingly. Since each layer will become a mesh, your player will not be
able to move behind tiles as expected. I actually got the chance to meet
Sean at SXSW and we talked a bit on this very issue, and didn’t come up
with a generic approach to the problem.
Keep in mind Sean’s tool is a lot more polished than mine and I’m kinda
expecting anyone who uses UTiled at this point to be comfortable with
diving into the code. It’s why I’ve not added it to the Tiled wiki (and
plus there is no real documentation yet).
As for the problem of walking behind tiles, there’s only two solutions I’m aware of:
Make sure you can sort the tiles and the characters together before rendering them. This could mean not rendering them as part of the mesh, but possibly instantiating “sprite” objects for the relevant tiles. For performance reasons you’d still want to use a mesh for the background and foreground layers. This is the approach I took in the Source of Tales client.
Use the Z-buffer to have the right pixels get discarded. This way the order in which you render the tiles and the characters does not matter, but it can’t generally deal with semi-transparent pixels. This approach was available in cocos2d-iphone and is still available in Cocos2D-SpriteBuilder (see CCTiledMap).
Looks like my fancy inline reply’s got cut by the forum - live and learn!
Here is the rest of the email:
Make sure you can sort the tiles and the characters together before
rendering them. This could mean not rendering them as part of the mesh, but
possibly instantiating “sprite” objects for the relevant tiles. For
performance reasons you’d still want to use a mesh for the background and
foreground layers. This is the approach I took in the Source of Tales http://www.sourceoftales.org/ client.
Unity attaches a “gameobject” to each sprite in the scene, which becomes an object the GC has to deal with. It doesn’t take too many of these for tiles to bring the game and IDE to a crawl. This is why all the tile engines in Unity go with a mesh.
In UTiled a sprite object is brought in as a sprite in Unity so you could do this approach but…
Use the Z-buffer to have the right pixels get discarded. This way the
order in which you render the tiles and the characters does not matter, but
it can’t generally deal with semi-transparent pixels. This approach was
available in cocos2d-iphone and is still available in
Cocos2D-SpriteBuilder http://cocos2d.spritebuilder.com/ (see
CCTiledMap http://cocos2d.spritebuilder.com/docs/api/Classes/CCTiledMap.html).
Unity sprites get a “sort order” unique to the sprite shader, and meshes use the Z-Buffer. I’ve had mixed results when trying to combine the two. There is probably a way to get them to play nice that I haven’t found yet.
I found out about https://bitbucket.org/Chaoseiro/x-unitmx/wiki/Home which supports isometric maps, however they are a bit buggy for me atm so I might check your way if I dont get it working. Thanks for the answers!
Right, since sprites can be a little expensive I was creating them only for the visible area of the map and dynamically adding/removing as the view scrolled.
Another idea would be to use a mesh for each row of tiles. It’s not optimal, but it’s better than rendering each tile separately and still allows for correct drawing order.