Animated Tile Sets in Unity 2021
AKA Scripable Tiles
Per Unity’s documentation:
“An Animated Tile runs through and displays a list of Sprites in sequence to create a frame-by-frame animation.”
“Create the Animated Tile by selecting and ordering the Sprites that makes up its animation sequence in the Animated Tile editor, then paint the Animated Tile with the Tile Palette tools.”
In Unity 2021.3 LTS, the “2D Tilemap Extras” package should already be included with 2D Core Template we used to create our project.
If for some reason it’s not, please download and import it.
Contribution by: MahdiMahzuni An Animated Tile runs through and displays a list of Sprites in sequence to create a…
We’ll demonstrate animated tiles with the same example as Unity, a waterfall.
Using the Right Sprites
The first thing you’ll need to get your hands on is a collection of sprites that when viewed as a flipbook appears to animate.
Above I’m using a waterfall provided by GameDevHQ’s Filebase.
We can see the effect simply by scrolling through each sprite generated from the texture file.
Create Animated Tiles
We’ll be creating three different animated waterfall tiles.
Simply create an appropriate folder to store them in your Project Assets folder, then right click, go to Create > 2D > Tiles > Animated Tiles.
Name the files appropriately.
When you select one of your animated tiles, you should see something similar to the above in the Inspector window.
For each animation tile, we’ll enter the number of associated sprites.
The Waterfall_Center example is shown above.
Add each sprite associated with the animated tile in the correct order.
You can do this by typing in the name of the sprite as shown above, or by dragging each sprite from the Project window to the Inspector window.
Repeat this process for your other animated tiles.
Once that is done, we need to modify the Minimum and Maximum Speeds.
This may take some trial and error, but since I had 30 frames I started with a value of 30.
This seemed to work fine for me, but your mileage may vary.
Create a New Palette
In the Tile Palette window, create a new palette as shown above.
Now drag the newly created animated tile objects into the new palette and move around as desired.
Test it Out
Drag an animated tile from the palette to a desired Active Tilemap and hit play.
Your tile should be animating nicely.
Paint & Play
Paint the tiles as desired on a tilemap whose sort is in front of the other tilemaps and hit play.
You should have something like that shown above!