Day 111: Introduction to Tilemap in Unity

Objective: Set up the Tilemap system in Unity.

We will start to add everything we need to, to work with Tilemaps. Tilemaps helps us paint out levels with 2D sprites.

In our Hierarchy, let’s create a 2D Tilemap.

After the grid is created, there is a tilemap set as a child to the grid.

We will need to open our Tile Palette. We will go to Window → 2D → Tile Palette. A window will open up.

This window will allow us to drag sprite sheets in and allow us to paint on the map. To add the sprites we will need to go to our sprite sheet and make sure the Texture type is Sprite(2D and UI), Sprite Mode is Multiple, and the Pixels Per Unit is set to the right size for your sprite sheet. The one I am using is created as 128 x 128.

Next go to Sprite Editor to make sure it is spliced correctly.

If it is not spliced correctly, we can go to the top click slice and change the type to Grid by Cell Size. For the Pixel Size, set to the dimensions that your sprite is set as.

After Sliced, click apply on the top right side of the window.

Next step is to Create a new palette for the sprites to sit on. In the Tile Palette window we will go to the drop down under Active TileMap and select Create New Palette. Save in the asset folder. I have created a Folder named TileMap and inside that another for palettes.

After that Is created, the Palette will be empty. We will drag our sprite sheet from earlier and drop it into the new Palette. We will need to save it as well.

Now we have sprites to paint.

In the row at the top select the paint brush and a tile. What ever tile is selected and be painted on the tilemap.

If you want to make a background and midground and more, under grid create more tilemaps. When painting you want to make sure the active tilemap on the Tile Palette has the correct one selected.

Each Tilemap has a Tile Renderer. The renderer will allow the layers to be painted above or below another layer. To do this, you will need to set each renderer layer at a different layer. We set background to 0 and moved up as we got closer.

Last thing we will do is apply a collider on the ground Tile Map so we can walk on it. Select the ground layer and add a TileMap Collider 2D. This will add a collider to each tile painted on the tile map.

This will add a collider to each tile painted on the tile map. To fix this we will need to add a Composite Collider 2D. This will automatically add a Rigidbody 2D.

The last thing to do is on the TileMap Collider 2D. Select Use by Composite. This will only do the outer side of the painted tilemap.

This is all for the Tile Maps.

Thanks for reading and have a wonderful day!!

--

--

--

I am passonate on learning to program and use Unity to become a skillful Unity Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

5 Most Useful Linux Commands For Beginners

How to write meaningful tests

How visualization helped a team to deliver more value

Is your Lightning Component secure ?

CDC Internship Diaries

Git Working Areas

My Journey from TCS to SDE, Amazon!

CS373 Fall 2020 Final Entry: Jesse Zou

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
Tyler Smallwood

Tyler Smallwood

I am passonate on learning to program and use Unity to become a skillful Unity Developer

More from Medium

Day 112: Animated Tile Maps

Altering Texture Maps with Gimp

The new Input System: Create your first input asset

git it on the page!