Loading lessons...
2D Tilemaps
2D Tilemaps
The Tilemap system lets you build 2D levels quickly using small, reusable building blocks called Tiles. It is similar to painting tiles onto a grid.
Grid and Tilemap Components
To create a Tilemap:
- Go to GameObject -> 2D Object -> Tilemap -> Rectangular.
- This creates a Grid GameObject with a child Tilemap GameObject.
- The Grid defines the layout geometry (cell size and gap).
- The Tilemap component stores the layout data.
- The Tilemap Renderer component draws the tiles.
The Tile Palette
To paint tiles, you use the Tile Palette window (Window -> 2D -> Tile Palette):
- Create a new Palette.
- Drag your sliced Sprites into the Tile Palette. This automatically generates Tile Assets.
- Select a tile in the Palette, select the Brush tool, and paint directly onto the grid in the Scene View.
Collisions on Tilemaps
Instead of adding separate colliders to every single GameObject, you can add a Tilemap Collider 2D to the Tilemap GameObject.
- Every tile with a collision shape defined will automatically generate physical boundaries.
- To optimize performance and merge adjacent box outlines into a single smooth path, add a Composite Collider 2D to the Tilemap GameObject, and check the Used By Composite box on the Tilemap Collider 2D.
TL;DR
- Create Tilemaps nested under a Grid GameObject.
- Tile Palette is the paint toolbox for selecting and brushing tiles.
- Tilemap Collider 2D adds collision shapes to drawn grid cells.
- Use Composite Collider 2D to combine individual cell outlines into unified collision shapes.