Automap tile properties to object?

Hello!

I’m trying to figure out a way to place enemies on my map using tiled, and then get them instantiated as a prefab in unity.
In unity I already have the enemies made and working, but having to manually place them at the correct spot is tedious and error prone, so it would be way easier if I could place the enemy locations within tiled.

My main question is this, am I going in the right direction or am I doing things needlessly complicated?


Currently I have a small test tileset with the two enemies on it, each tile has a custom property “enemy” with the value “enemyname”.
Now I’ve been able to make a automap rule which makes a tileobject with the properties I want, by setting the properties of the object manually in the rule file.

I could manually make rules for every enemy and fill in the object’s properties for each one but that would involve a lot of tedious work so there might be a simpler way.

An alternative I’m looking into is to parse the .tmx file myself and create these objects myself,
either based of information filed into the tile properties or reading of some xml file with the values in order of the tiles on the tileset.

Why did you choose to rely on an automap rule for this, rather than just placing your tile objects directly? You can associate any needed custom properties with the tile itself, instead of duplicating them for each object instance.

Possibly @Seanba could weight in on how to use Tiled2Unity effectively for this use-case.

Hi Mazy, I probably wouldn’t use automapping for these but instead have a tileset that represents the different sprites I want to instantiate in the map. I would place those “sprites” in the level in Tiled using an Object Layer with Tile Objects. Then, I would write a custom importer script (in Unity) that knows how to replace those Tile Objects with one of your prefabs.

There’s an example of this on my blog here: http://www.seanba.com/megadadadventures.html

2 Likes