Destructable Environment

Hi,

I’m creating a game in unity and am wondering if Tiled + Tiled2Unity is a good solution for what I want to do.
I need each tile on one Tiled layer to be it’s own Unity gameobject with spriteRenderer and polygonCollider2D components.
Is this possible; does anyone have experience with this?

Thanks!

@Seanba will correct me if I’m wrong, but that’s not the use-case for which Tiled2Unity was developed. Of course, there are probably more optimal ways of implementing destructible environments than the approach you’re suggesting, possibly also including the use of Tiled2Unity.

If you really want to set up a game object for each tile (I hope your map isn’t too large then), you should probably use a library like X-UniTMX. You can find all known options for using Tiled maps in Unity here:

http://doc.mapeditor.org/reference/support-for-tmx-maps/#unity-3d

Bjorn is right that representing every tile as a GameObject is not the use-case I had in mind for Tiled2Unity (I would additionally argue that isn’t an optimal approach for any game design as maps grow with O(N^2) complexity).

However, Tiled2Unity could be made to support something like this with clever use of Automapping and Custom Importer scripts. (I do this often, btw, just on a smaller scale.)

See the TileObject Approach in this post: http://www.seanba.com/getting-tile-information.html
Also, see how I added spawners for “appearing blocks” in this post: http://www.seanba.com/megadadadventures.html

Be warned though: Your game design may be a bit ambitious if you’re new to game development. My hard-earned experience has taught me that game development complexity skyrockets with the amount of content that is interactive or can change state in realtime. Good luck on your game all the same :slight_smile:

1 Like

Thanks for the response and links bjorn! This information is very useful. I’ll look into these options as I really love the functionality of Tiled.

Thanks for the insight, Seanba! I’ll see if these options suit my needs, and think hard on your advice.

As Seanba, you could use Automapping and custom importer to do the job.
In my Unity game, I use Tiled to draw all interactable objects too, like spikes, enemies, turrets, coins, and much more.
The, I use Automapping to change those to Objects. And I use a custom importer to change Tiled’s images with the correct prefabs. (In Tiled, I have for example a custom property: “PrefabName: turret”, and load the prefab named “turret”)


Btw, I have a question regarding that, if I could do it here?
In the custom importer, when getting the position, I think Tiled have origo at one of the corners, and Unity has in in the middle. So I have to give it an offset to place the prefabs correctly.
Is there a setting in Tiled that can change the origo of the objects to “center”? If not, it would be great to have one.

Not yet, but I agree this would be nice to have. There’s the following issue about this on GitHub: