Sean Barton - Game Developer

Previewer Improvements with Tiled2Unity

09 March 2015

Hi there! Tiled2Unity is no longer in development nor supported. Use SuperTiled2Unity to import Tiled Map Editor maps into your Unity projects instead.

Note: My Tiled2Unity utility is available for download on this page. Also, please consider contributing to Thorbjorn Lindeijer’s Patreon for continued Tiled Map Editor support.

I’ve been working on an upcoming Tiled2Unity tutorial to help people that are trying to get information for a specific tile at a specific location at runtime.

For instance, say your working on a game like Advance Wars where the game logic has a dependency on the type of tiles that make up a level (grass, trees, mountains, etc.)

Advance Wars 2 (Copyright Nintendo)

Achieving this with Tiled2Unity is done through having all the different tile types (with collisions) on separate Tile Layers and using a raycast against their generated PolygonCollider2D objects. This gives you the ability  to know which “type” of tile you are “using”. Further, I use Tiled’s Automapping capabilities so that I only manage one Tile Layer and let the Automapper take care of the rest. (More on that in the upcoming tutorial.)

The idea isn’t that difficult but the previewer in Tiled2Unity was a huge disappointment for a map with multiple collider layers. Here is a screenshot of it in action …

Can't see collisions

What a mess. There’s six different kinds of polygons in that picture (plus a bunch of rectangles to indicate sprite location) but it’s impossible to tell where they are.

So, the latest versions of Tiled2Unity has previewer options …

Right-click to bring up Previewer Options

… that allow you to select which layers are being shown in the previewer. They also allow you to choose a color for the collision polygons on a per-layer basis:

Previewer Options (Per Layer)

(BTW, the color settings are saved to file so that you don’t have to reset them every time you use the previewer. Other maps that use similar layer names will inherit these colors while previewing.)

Now we can get a much better sense of how polygon colliders are going to be created in Unity.

Much better view of collisions

We can take this one step further. The collision layers in this example (CollisionWood, CollisionMountain, etc.) make use of the unity:collisionOnly custom property. This tells Tiled2Unity that we only want collision polygons for these layers and ignores the mesh that would normally go with them.

Given this we can preview only these layers and get an even better sense of the colliders that will be created by Tiled2Unity. Notice how the blue water polygon stands out. (And yes, that’s one polygon in Unity.)

Viewing only collisions

What I like most about Tiled2Unity (and why I made it available to the public as a side-effect of my Mega Man game) is that all of this information for the map is going to be represented by just a few polygons – and not some O(N2) number of per-tile objects.

And now, it’s easier to see that in the previewer. Happy developing.

Seanba

Hi! My name is Sean Barton (aka Seanba).

I’m an American-Canadian software developer working in Austin, Texas where I never have to shovel snow. :fire:

My career focuses exclusively on video game software and tools. You can read more about me here.


Aseprite2Unity

Aseprite2Unity imports sprites and animations for use with your Unity projects. Like all my tools it is available for free or name your price.

Get Aseprite2Unity.


SuperTiled2Unity

SuperTiled2Unity is a collection of Unity scripts that import Tiled Map Editor files to your Unity projects. You can download for free or name your price.

Get SuperTiled2Unity.

(Note that regular Tiled2Unity is now deprecated.) :zzz:


Seanba

Like my tools? Consider making a donation as a way of thanks!