Falling Tiles / Destructable Tiles

Hiya, first time poster here.

Been using Tiled for maybe 6+ months or so, in combination with Tiled2Unity. It’s been working quite well given my limited experience with Tileset editors / auto-mappers. Thanks for the tool and the support.

How I Use It:
I typically just drag and drop .tmx files into Unity 2D projects, the collision bodies of these tiles have been defined within Tiled Editor, and that’s been enough for me. I define most everything else in Unity world space (i.e manually place transforms, sprites, player/enemy GameObjects, collisions, etc.). I say this to express that I don’t have experience with much else that I’m sure Tiled has to offer, how it can be used more efficiently, and APIs, other scripting methods, custom files, etc.

I’d like to learn more!

Anyhow, the question that I have today is,

Hypothetically, if I wanted to make falling tiles or destructible tiles (think Zelda II or Castlevania, NES tile properties), where not every tile in the scene need have physics applied or be destructible, but I’m getting to a place where I’d like to find out how to do this, and how it might be possible using Tiled + Tiled2Unity.

Curious if anyone here has achieved such a result, i.e. can a tile on a specific layer within the .tmx, imported into Unity, have destructible qualities, and or the ability to have physics applied directly?

If the answer is “No”, just do this with a custom Unity gameObject/prefab that just appears as a 16px sprite and has a Rigidbody2D, that’s fine too.

Although that being said, I’ve never tried using Tile2Unity (tmx files) in combination with Unity Grid, can they work in tandem, in this way?

Thanks for any feedback you can provide.

Have a great day!

Rob

When you say Tiled2Unity, do you mean Tiled2Unity, or SuperTiled2Unity? ST2U can definitely do what you want, I don’t know about the old T2U.

ST2U has a “prefab replacement” feature that you can use to fairly easily replace any Tiled Object with a prefab. There’s an example of ST2U prefab replacement here. So, you’d place your destructibles as Tile Objects in your map, and use a custom property and some Unity-side scripting on your prefabs to have ST2U replace those Objects with your prefabs.

If you have a lot of destructible tiles to place and would prefer to use a tile layer instead of making individual Tile Objects for each one, you can do that too. You’d create a tile layer for your destructible tiles and draw them on it, and in Unity, you’d turn replace each tile with its corresponding prefab. For this, I think you’d need to extend ST2U. In your extension, you’d find the tile layer (by a custom property or by its name), iterate its tiles, and for each tile, place the relevant prefab at its location. You’d then probably remove the tile layer (Unity-side, not in Tiled) since it’s no longer needed.

Thanks so much for the info.

I will have a look at the provided links when I’ve a spare moment, prefab replacement sounds very promising!

To confirm I’m using SuperTiled2Unity 1.10.7!

I’ve successfully turned a Tiled “object” into a Unity prefab, using the prefab replacement method you so helpfully described. Easy as pie.

Marking your response as the correct solution.

Thank you!

1 Like