Creating Tilemaps in Unity
Setting up a scene in Unity with tilemaps can an effective way to speed up the level creation process…Unfortunately, it can also be a little awkward to get used to at first.
Create a new game using the 2D template:
The tile palette window is where we create tilemaps that can be used to ‘paint’ in the scene. The Tile Palette window can be found under Window > 2D > Tile Palette:
In order to create tiles, you will first need an image. Itch.io has a wide range of free images to use or you can use one like this from GameDevHQ’s Filebase:
With our image selected in the Project window, we need to change make sure the texture type is Sprite (2D and UI) as well as make sure the Sprite Mode is set to Multiple. Click Apply and then click Sprite Editor:
With the sprite editor open, we need to splice the tiles so that they are separate tiles. If we know from the artist what size the tiles should be we can set manually. If the images are spaced apart, we can also choose automatic:
With our first set of tiles created, we can now create a palette. After clicking Create in the Palette window, we will be prompted to select a folder to store our palette. We then need to drag our newly created sprites into the new palette window. This will prompt us to locate the folder for our tiles:
In order to use our tiles, we need to create a grid. This can be done by right-clicking, selecting 2D Object > Tilemap > Rectangular:
Back in the TilePalette, we can now select which tiles we want in our scene and simply paint them in the scene view:
For any areas we don’t want, we can simply drag to get the size of eraser we want then click the erasure tool, and finally drag to delete the areas we want removed: