Tilemaps are a great way to design levels in Unity. They are extremely useful in separating content in layers . It is very simple to use a Tilemap in unity. In this post, we will explore how to create and use Tilemaps to create amazing levels for 2D games.
In combination with the Tile Palette, which holds TileAssets, this is a truly comfortable features in designing levels.
1. Create a new Tilemap GameObject
After adding a tilemap to the screen, you will immediately see a Grid in the Scene panel. In order to use the Tilemap , we need to setup the TilePanel .
2. Set up the Tile Palette Window
3. Create a new Palette
Inside the tile palette window, you see an option to Create a new Palette. We can create Multiple Palettes . For example , Background palette to store all sprites related to background layer.
4. Create TileAssets using Sprites
You can use your existing Sprites to create Tile Assets. Simply drag them into the BackgroundPalette that we just created, and it will create the corresponding Tile Assets.
By dragging the Parent sprite, all the slices will be imported and are available individually.
5. Painting Tile Assets on Tile Map
Now you can paint the TileMap with the assets present here. Using the Paintbrush tool in the TilePalette, we can draw the TileAssets on to the TileMap.
6. Creating a second TileMap
Lets do step 1 to 5 again for a new Tilemap. We’ll call it the Foreground Tilemap, and start painting from the Foreground Palette on to it.
- Lets create a second TileMap called Foreground.
- Also create a new Palette called ForegroundPalette.
- Import a new Parent sprite into the ForegroundPalette.
I have selected the “Focus on” setting in the Scene editor to “Tilemap” which focuses on the currently active Tilemap