Tilemap — Using Tilemap in Unity — part 1

In this article I will go over how to set up and use tilemaps in Unity.

Setting up Tilemap

First we need to set up our tile pallet and a grid for our tilemap. Go to “Window” > “2D” > “Tile Palette”.

This will open the Tile Palette window. Now in the Hierarchy window right click and select “2D object” > “Tilemap” > “Rectangular” (or the most appropriate grid for your project).

Setting up layers and palettes

Now lets separate our tilemap into layers. This is as simple as adding a child object to the grid object and adjusting the sorting layer on each as required. I have created 4tilemaps at different orders in the layer (Foreground: 10, Ground:0, Midground: -10, Farground -20).

Next lets create some palettes. Palettes are sliced imaged that can be used with brushes to basically ‘paint’ an environment. I am going to create our ground palette.

In the “Tile Palette” window change the “Active Tilemap” to the layer you want to create the palette for. I will start with our ground objects. Now select “Add New Palette” in the drop down. This will give you a window where you will save the tile palettes. I will create a new folder structure “TileMaps” > “Pallets”.

Setting up your sprites

The next step is to add in our sprites to our palette. I have downloaded a sprite designed to be sliced for this purpose. You can find many of these assets on the asset store or by searching online for free game art.

To slice up a sprite for your palette, you need to click on the texture asset and change the “Texture Type” to “Spite (2D and UI)”. This is where your own understanding or your asset will take over. With my sprite the artist has set the asset in a grid of 128x128 pixels. So we can change the “Pixels Per Unit” to 128. Now you can change the “Sprite Mode” to “Multiple” then click apply. Now your sprite is ready to be sliced.

To slice your sprite click the “Sprite Editor” button. For my asset I need to click “Slice” and change the “Type” dropdown to “Grid by Cell Size” and change the “Pixel Size” to 128x128. Once you’ve set up your sprite you can press the “Slice” button then click “Apply”.

In your asset folder you will see that your sprite has been sliced into multiple sprites based on your specifications. This now allows us to drag the sprites over to our pallet to convert the sprites into tile assets. This will give us a window to save our Tiles. I am creating a new child folder structure to keep things organized in the “Tilemap” folder. This will be “Tilemap” > “Tiles” > “Ground”.

Painting with the Tilemap Palette

Now that we have some tiles to work with we are going to paint the environment. In the simple terms all you have to do is select a tile within your palette and click and drag the mouse while you have the brush tool selected. You can select single tiles or multiple on your brush.

In the “Tile Palette” window you’ll notice a bunch of tool icons”. From left to right they are:

Select tool: allows you to select an area of the grid.

Move tool: allows you to move your tiles in the tile palette. You do this while in edit mode- you select your tiles, click edit then click the move tool.

Bush tool: allows you to paint with your active brush.

Box tool: allows you to paint a filled box with the active brush. This tool will basically insert the selected tiles into your scene.

Eye drop tool: allows you to sample a tile/tile set with add it to your current brush.

Erase tool: allows you to erase tiles. You can change the size of the erase tool by selecting a larger area in your tile palette.

Fill tool: allows you to quickly fill in an area.

By switching between layers and palettes you can begin to create detail into your levels.

That's all for now.

--

--

--

Unity developer with a love of learning all things programming.

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

Recommended from Medium

BUILDING YOUR CUSTOM CRM

Beyond A/B Testing: How to Optimize Anything

Bifrost Network | 120 KSM Airdrop Rewards Announcement

Review of Udacity’s Deep Learning Nanodegree program

Kubernetes on Bare Metal

People of Golem: team Clay takes the spotlight

Safe, extensible interrupts/syscalls, a.k.a. Algebraic Effects

Horizon product update: APIs added to further streamline KYC/AML compliance checks

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
Luke Duckett

Luke Duckett

Unity developer with a love of learning all things programming.

More from Medium

Journal 148 — Unity Project Development, 2.5D Shooter

Adding a new ability to our prototype — The Triple Shot

Framing Transposer Virtual Camera Explained in Unity’s Cinemachine

Unity and Cinemachine — Virtual Camera Aim Options