Nerd For Tech
Published in

Nerd For Tech

Introduction to Tilemap in Unity

2D Mobile Game

Objective: Learn to use tilemap to create a level

Right click on empty area in the Hierarchy, go to 2D Object>Tilemap>Rectangular

This will create a rectangular grid on your scene view where you will be able to paint tiles. You can name it to whatever fits your need, here I will be renaming it to Ground_Tilemap.

Then inside the Tile Palette, select Ground_Tilemap if not already selected. This need to be done because later you might create more tilemaps like background, foreground for decorating your scene. So when you paint your scene in ground tilemap, the gameobject placed on same level as the tilemap will interact with all the tiles on that layer ignoring other tilemaps in other layers.

So what is a layer you may ask, its basically a way to tell the game that they are placed on different places like a row of people. The two tilemaps with different sorting layer will not interact with each other. The one with higher sorting layer will be in front of the tilemap with lower sorting layer and if on the same layer then the game will place the tile behind the one that already exist.

To paint the tilemap, you need to add a texture inside the tile palette. To do that, you need to import your texture and then set the Texture type to Sprite and Sprite mode to multiple so that we can break it down and use individual tile instead of the whole sprite.

Then you need to go to the Sprite editor > Slice > Grid by cell size > Slice.

Make sure that the pixel size matches the cell of the texture.

Now to add this sprite for use, we first need to create a palette to store these sprites. So Below the Active tile, you will see a create new palette. click it and give it a name then you will create a folder to store all the palettes you will create in the future, select the folder and you can now drag the sprite to that palette to draw a scene.

Now you can create different tilemap with different sorting layer, create new palette to store different texture and design your scene with awesome background and ground level.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store