LDtkToUnity icon indicating copy to clipboard operation
LDtkToUnity copied to clipboard

Possible to get animated tiles?

Open yiliansource opened this issue 2 years ago • 7 comments

Since LDtk has yet to implement animated tiles, I was wondering whether there was a possibility to inject an animated tile during the import process. The usecase is an animated water tile. I'd appreciate any ideas!

yiliansource avatar Dec 05 '22 21:12 yiliansource

It's something I plan to allow easy support for, but you may be able to do some coding on your end to replace certain tiles with a custom animated tile of your own from 2d extras. Another option is to make your animated tiles as entities. It's something I eventually want to get to.

Cammin avatar Dec 05 '22 21:12 Cammin

Do you have an idea on how to do such a replacement? Any pointers would be really helpful.

yiliansource avatar Dec 05 '22 23:12 yiliansource

One way is to make a prefab with the animation as part of the prefab. Then you can either make entities for each animated tile, or create a dedicated intgrid layer for the animated tile. You can only assign one prefab per entity or intgrid, so it's a bit of a manual process. Using the entity method will allow you to make animated tiles of different sizes since you can control entity size and aren't limited to the size of a grid cell (this isn't the case if going the intgrid route since those are tile based).

pinwizkid avatar Dec 06 '22 00:12 pinwizkid

That makes sense.

Do you think it's possible to access the actual tilemap during the import step, so you can replace dedicated auto/rule-tiles with their animated counterparts? Are the tiles exposed during the import process?

yiliansource avatar Dec 06 '22 08:12 yiliansource

It would be possible to access the tilemap in the import process via the LdtkPostprocessor class, but since the tiles are generated every reimport, it would naturally be difficult to have an exposed reference to the tiles.

You may be able to define a string of the tiles you want to replace. Each tile is named according to a specific convention: "TilesetName_x_y_w_h" You should be able to iterate though the tilemap and check the names of particular tiles to figure out which ones you want to replace. It's not the easiest process, but it's something doable right now. I have plans to make this easier, but it shall come in due time when it does 🙂

Cammin avatar Dec 06 '22 18:12 Cammin

I thought it supported this but sadly it doesn't. Would be a great addition although I'm sure it'll be lots of work. Hope to see it sometime 😄 Keep up the great work and thanks for this tool!

devingDev avatar Sep 06 '23 13:09 devingDev

Yeah, since LDtk doesn't have a concept of animated tiles, I'd invent a custom solution. This is a feature that will need to come after I get the tileset def update working perfect. I have subtle plans for animated tiles and stubbed some initial code, but it needs to wait for some other stuff that I'm cooking 🙂

Cammin avatar Sep 06 '23 16:09 Cammin

I got animated tiles implemented in the new update! (5.0.0) Give them a try and let me know if there are any problems. Here's the guide: https://cammin.github.io/LDtkToUnity/documentation/Topics/topic_AnimatedTiles.html

Cammin avatar May 06 '24 03:05 Cammin