Warning: This is an old post! Animation support in Tiled2Unity is now greatly optimized as of release 22.214.171.124. You can now be more confident that a large number of animations will not sink performance as before.
Thanks to prodding and pleading by users I’ve decided to bite the bullet and add support for tile animations that newer builds of Tiled Map Editor allow through its Animation Tile Editor.
In a previous tutorial I demonstrated creating animations by using a combination of layers, tags, and specialized runtime behaviors. This approach is much better.
Like everything I else I try to do with Tiled2Unity, the animations from Tiled just work without any extra modifications. To achieve that, I’ve added a
TileAnimator script that is automatically added to your prefab during the import process if animations are detected.
Word of warning: Tiled layers are represented as meshes in Unity. In order to support animations the TileAnimator instances must modify these meshes in real-time. Under some conditions and platforms this may degrade performance. (I doubt it will be any worse then other attempts at animating tiles though.)
What You’ll Need
In order to get Tiled animations into your Unity projects through Tiled2Unity you will need the following:
- Tiled2Unity version 0.9.5.3 or later (download here)
- A daily build of Tiled Map Editor that support the Tiled Animation Editor. I used the Aug 1st, 2014 build. (download here)
As of this writing the collision and animation editors in Tiled are not in a stable build, hence the need to get a daily build.
Being a big fan of the Zelda series I’ve taken a room out of the Desert Palace from The Legend of Zelda: A Link to the Past as an example. I like how the animated water and lamps bring a bit of life to the room – and no custom scripting or sprite objects are needed.
You can download the example project here to see it for yourself. It includes both the final Unity project and the source Tiled files (map and textures).