Journal 92 — Unity 2D Mobile, Dungeon Escape TileMap Practice

Chris Nielsen
5 min readSep 20, 2021

Objective: To learn about TileMap setup for a 2D mobile game

In this next article, I will go over a general TileMap workflow in Unity 2D.

First we need to add a 2D Rectangular TileMap game object.

Then we need to create a Palette. You can save this in a subfolder of your choice, such as \Timeline\Palettes.

Ground Palette

After this, we need to set up the ground palette. We can go to the ground assets and change the 2D sprite by slicing into 128x128 pixels and applying the changes.

After this you will see the ground sprite was sliced into individual tiles.

Now we can drag the sliced up Ground sprite into the Tile Palette window.

Paint Ground

Let’s try painting the ground. We can first select the Paint Tool in the Tile Palette and select a specific tile or drag the mouse over a group of tiles to use as a paintbrush to apply to the scene.

We can modify the tiles and create a gap that the player has to jump over.

Cavern Palette

Next we will add a cavern palette. We have three types of caverns in our assets that we can add and switch among to paint.

We can start with slicing the Black_Cavern_2 tile, and dragging the sliced up tiles to the Tile Palette.

Next we can add the Far_Cavern. We can use a slightly larger tile size at 256 x 256.

As you can see, in the Caverns Palette, we can now switch among the different cavern tiles to paint with. Let’s adjust the gap slightly between the two sets of tiles. We can select “Edit” in the Palette, and select and move one of the cavern tiles, then select Ctrl+S to save the edits.

Let’s add one more cavern called Grey_Cavern.

Vegetation Palette

Let’s add a vegetation palette with the same process.

Midground Caverns

Let’s create a new TileMap to show cavern art further in the scene background. We can also set the sorting layer to -1.

Now, let’s paint some caverns just beyond the foreground.

Farground Caverns

Now let’s create a background or farground set of caverns to fill in the holes in the scene. We will create a new Tile game object, and let’s simplify the order of the objects in the hierarchy by setting the background to 0 layer, midground to 1, and ground tilemap to 2.

Foreground Layer

Next, we can add some foreground objects such as vegetation, barrels and rocks to the scene. We can create a new Foreground tilemap object, and we can keep this on the same layer order as the ground surface. We can also adjust the game object y-value so it blends with the rock ground surface. Alternatively if you would like the player to look like they are walking on the ground surface but behind the vegetation and other foreground objects, you could set the Foreground layer higher, such as at 3.

Next, we can add additional foreground items like barrels.

We can also add spikes at the opening in the ground. We can slice the sprite sheet in the assets to the correct tile size, and for this example, we just want the spikes, so just find the individual spikes sprite and drag it and add it to the other Foreground tiles.

In a follow up article, I will go over adding in animated tile sets.

Thank you for your time!

--

--

Chris Nielsen

An Engineering Manager consultant who is seeking additional skills using Unity 3D for game and application development.