Unity Development — Animated Tiles

Christopher Graf
4 min readSep 14, 2021

--

If you have been playing with Unity’s Tilemap since it was first introduced to you, bravo. I hope you are enjoying it and have found some new and excellent ways to build your levels. There are two things I would like to add to the basics now.

Creating a level out of tiles does not really serve a purpose if the player cannot walk around. When painted on, the tiles are simply small sprites to create a visual aesthetic. You can grab a specific tilemap and add a tile map collider, allowing objects to have physical interaction.

There is a bit more too it than that though. If you leave the tilemap as is, it will have a separate collider for each and every tile. There may be some uses for this, but it does not correctly for a tilemap that is meant to be a walkable ground.

To fix this, add a Composite Collider 2D component to the tilemap. This will automatically add a Rigidbody 2D as well.

Set the ‘Body Type’ on the Rigidbody 2D to Static. Saves the engine a lot of processing, knowing the tiles are going to be staying still. Also, no gravity to make them fall.

Make sure to turn on the ‘Used By Composite’ attribute on the Tilemap Collider.

Now the tilemap will have a proper collider to cover the area correctly.

The second thing we should add to our Tilemap resume are animated tiles. These can create some amazing effects, like waterfalls. Depending on the some Unity updates, this may or may not be already installed and available. You can check with the first step of creating an Animated Tile in the Project Window.

if this option does not appear, you’ll have to open the Package Manager, make sure it is set to see Preview Packages. Once there, download 2D Tilemap Extras.

Once that is all set up, go back to the original step and create an Animated Tile in a proper folder of your choosing. These are very different from other tiles.

In the Inspector for each tile, you’ll be able to set the number of sprites for the animation. If you have a spritesheet, it would help to know this number when creating the animation, just as with a regular animation.

Unfortunately, unlike making other animations in Unity, you’ll have to individually click and drag each sprite to complete the animation. At the bottom, you can then set the speed at which you want it to run.

Make a new Tile Palette, if you don’t want to place it anywhere else, and simply drag the animated tiles into the palette window.

Now you’ll be able to paint with these tiles like any other. Only difference being, when you play the game, you’ll see the animations come to life.

Your Tilemaps skills have now advanced. Keeping pushing along and see what kind of levels you can make that you never thought of before.

--

--