Tip of the Day: Tile-Maps 101 Unity2D

Mohamed Hijazi
Nerd For Tech
Published in
4 min readMay 15, 2021

2D games are always fun to make once you put your passion and enthusiasm in your project. 2D games in Unity can be done through prefab gameObjects, but also they can be made through Tile-Maps.

Tilemaps are almost like a real map, you use them to draw your world and levels.

Tilemap example

According to Unity Docs, “The Tilemap component is a system which stores and handles tile assets for creating 2D levels. It transfers the required information from the Tiles placed on it to other related components.”

Objectives: How to setup Tilemaps?

First off, you have to be create a 2D project because this will allow Unity to automatically install most of the 2D packages including Tilemaps.

To start, open the Tile Pallets window: Window > 2D > Tile Pallet

Tile Pallet window

Tile pallets are drawn on a Tilemap gameobject, it is basically the grid that you use to draw on.

Create > 2D Object > Tilemap > Rectangular (the most common)

This will create a Grid parent gameobject and as a child, it will create a Tilemap layout.

Grid

Let’s create a Tilemap pallet that we will use to draw on the grid.

In your Tile Pallet window, “Create” a new Pallet, name it, choose the Grid type and Grid size. To populate this pallet, you will need a Tilemap asset which is basically sprites.

As you can see, the sprite mode has to be set to Multiple and you need to cut the sprite into individual slices that we will use to populate Tile Pallet. Now drag your sliced sprites into your created Tilemap above.

To start drawing your level.

  1. Open your Tile Pallet window
  2. Choose a tile to draw
  3. Choose Active Tilemap(the grid you created)
  4. You can paint individual cells, choose a group of cells, and you can even fill an area

Things to understand about tilemaps

A. You can create more than one grid Tilemap, for example one you use for the ground, one for the background and another for foreground.

In order to change their visibility, you can change the layout for each Tilemap. You can do this by changing the Sorting Layer of each Tilemap. This will bring forward or push back each Tilemap.

B. You can add colliders to Tilemaps, this allows your characters to walk and interact with Tilemaps.

Choose a grid to act as your ground.

Then add the following components to it:

A. A STATIC Rigidbody 2D.

B. Tilemap Collider 2D, here choose “Used by Composite”.

C. Composite Collider 2D, this will merge the individual cells of the Tilemap collider and allow for a smoother collision detection on your grid.

These are the basics of Tilemaps in Unity2D, from here your imagination is your limit.

A final tip before ending, you can use “Tilemaps Extra Package”, you can find it in the Preview Packages on Unity. This will add so many brushes and extra stuff to use with Tilemaps.

--

--

Mohamed Hijazi
Nerd For Tech

A knowledge seeking biologist who is following his passion into a full time career in Unity / Game Development. https://www.linkedin.com/in/mohamed-hijazi/