Unity Guide

Animated tiles | Unity

A quick guide about how to introduce animated tiles in Unity

Fernando Alcantara Santana
Nerd For Tech

--

Objective: Introduce animated tiles to a 2D environment in development with Unity.

In the last post I covered an introduction to work with tilemaps in Unity. Now, it’s time to introduce animated tiles to our new 2D environment in Unity to make the game look nice.

If you read the last post, you’ll remember that we’re using tilemaps (which are included in the 2D template of Unity’s projects) to design the level of our game:

Importing 2D tilemap extras

And now, in order to introduce animated tiles to our environment, let’s import the 2D tilemap extras package from the Unity registry. To do it, let’s start by opening the Project Settings and enabling the Enable Preview Packages option on the Package Manager tab:

Once enabled, we’ll be able to preview the 2D tilemap extras package on the Unity registry. To import the package into our project, let’s open the Package Manager window and then click on the Install button at the down right:

Creating an animated tile

Next, in order to start creating our first animated tiles, let’s edit and slice the respective sprite sheets. In this case, I’ll use 3 sprite sheets to create animated tiles that form a waterfall when used together:

Just as we did in the last post, let’s edit the sprite sheet properties and slice the image according to its size:

Then, to create the first animated tile, let’s right-click on a new folder and then let’s click on Create > 2D > Tiles > Animated Tiles:

Once the animated tile is created, let’s select it and drag the respective sprite sheet into the inspector. This will set the images in the order to display the animation frames while the game is running.

Let’s do these steps for the other sprite sheets as well.

Using the animated tile

Now, in order to be able to use the animated tile in our environment, let’s create a new palette within the Tile Palette window. Once created, let’s drag the animated tile files into the window:

Then, we can use the tools from the Tile Palette window to paint the animated waterfalls in our environment:

If we run the game, we’ll be able to see that the animated tiles update their sprites according to the sprite sheet provided:

The sprites are updated with a default speed of 1.

Modifying the animation speed

If we want the animation to be faster we can modify the speed by selecting the animated tile file and then change the speed values at the bottom of the inspector:

This will cause the animation to update 30 times per second.

And now, if we run the game with Unity, we’ll see that the animated tiles look better with more speed:

And that’s it, we introduced animated tiles to our 2D mobile game with Unity! :D. I’ll see you in the next post, where I’ll be showing how to setup our player for the 2D environment in Unity.

If you want to know more about me, feel free to connect with me on LinkedIn or visit my website :D

--

--

Fernando Alcantara Santana
Nerd For Tech

A passionate computer technology engineer and Unity developer that is always looking to grow in every aspect of life :).