Gridwright Start for $1

Autotile in Unity: Rule Tile Setup for 16 and 47 Tiles

Autotile in Unity with a Rule Tile: slice the sheet, fill the 3x3 neighbour grid for 16 or 47 tiles, order the rules, and fix seams and wrong corners.

Autotile Builder at work
Autotile Builder at work: Complete autotile sets from a small template.

You want a shoreline that draws itself. Unity can do it with a Rule Tile, but first you need the tiles: every edge, every outer corner, every inner corner where the grass bends round the water. Then each tile needs a rule, a 3x3 grid of arrows and crosses you click in by hand. You paint a test map and get a square edge in the middle of a lake, a corner that points the wrong way, or a thin line between tiles that flickers when the camera moves.

This guide sets up a Rule Tile in Unity 2022 LTS and Unity 6, shows which arrow goes in which cell for a 16-tile and a 47-tile set, and fixes the common faults. If you don't have the tiles yet, the Autotile Builder makes all 47 from one small template. You can try it here, with no account.

Why autotiles in Unity take so long

A Rule Tile looks at the 8 cells around a cell and picks a sprite by your rules. Eight neighbours that are each "same terrain" or "not" make 256 combinations. Most look alike, because a corner neighbour only changes the picture when both sides next to it are the same terrain: if the cell above is water, the top edge already covers the top-right corner. That leaves 47 different tiles, the blob set.

Autotile Builder in use
Autotile Builder in use. Every tool runs in your browser, nothing to install.

The smaller set looks only at the 4 sides: 16 tiles. It has no inner corners, so wherever the terrain bends inward, the edge breaks.

So it is 47 tiles to draw, then 47 rules of up to 8 cells each, and one wrong click shows only when a level has that exact shape.

Step 1: Install 2D Tilemap Extras

The Rule Tile comes in the 2D Tilemap Extras package, which 2D templates usually include. If the Project window's Create > 2D > Tiles menu has no Rule Tile, open Window > Package Manager, choose Unity Registry, find 2D Tilemap Extras and press Install.

Autotile Builder in use
Autotile Builder in use. Every tool runs in your browser, nothing to install.

Step 2: Import and slice the tile sheet

Drag the PNG into the Project window, select it, and set in the Inspector:

Autotile Builder in use
Autotile Builder in use. Every tool runs in your browser, nothing to install.
  • Texture Type: Sprite (2D and UI), Sprite Mode: Multiple.
  • Pixels Per Unit: your tile size, such as 16. A Tilemap cell is 1 unit, so each tile fills one cell exactly.
  • Filter Mode: Point (no filter).
  • Compression: None, on the Default tab.

Press Apply and open the Sprite Editor. Under Slice, set Type to Grid By Cell Size, type the tile size into Pixel Size, and leave Keep Empty Rects off. A border around the sheet goes into Offset, a gap between tiles into Padding. Press Slice, then Apply. For sheet.png, the sprites are named sheet_0, sheet_1 and on, left to right, row by row. The Unity sprite sheet guide explains every slice setting.

Step 3: Create the Rule Tile

In the Project window, right-click and choose Create > 2D > Tiles > Rule Tile. Select it and press + under Tiling Rules once for every tile in your set.

Christmas Village
Christmas Village: 16x16 top-down Christmas village: snow autotiles, lit houses, Santa, elves, reindeer, workshop, UI. One of the 150 packs in Gridwright.

Each rule has a sprite slot, a Rule setting, an Output and a 3x3 grid. Leave Rule on Fixed: a rotated copy of a tile puts its light on the wrong side. The middle of the grid is the cell being painted; the 8 cells around it are its neighbours. Click a cell to cycle it through three states:

  • Green arrow (This): that neighbour is this same Rule Tile.
  • Red X (Not This): that neighbour is anything else, an empty cell included.
  • Blank: it doesn't matter.

Step 4: Fill the 3x3 grid for each tile

For a 16-tile set, set only the 4 side cells and leave the corners blank. A side gets an arrow where the tile's terrain carries on past it, and an X where it ends.

Tower Defense Kit
Tower Defense Kit: Top-down TD kit: 8 towers x 3 levels that turn in 16 directions, 10 enemies, effects, roads, UI. One of the 150 packs in Gridwright.

For a 47-tile set, set the sides the same way, then each corner:

At that cornerCorner cell
Both sides beside it carry on, and so does the cornerGreen arrow
Both sides beside it carry on, but the corner doesn't (an inner corner)Red X
One of the sides beside it endsBlank

That blank keeps the set at 47: one rule covers both cases that look the same.

An example: terrain that carries on up, to the top right and to the right is the bottom-left corner of an area. With T for This, X for Not This and a dash for blank:

-  T  T
X  .  T
-  X  -

Step 5: Order the rules and set the Default Sprite

Unity checks the rules from the top down and uses the first one that matches. With every cell set as in Step 4, no two rules can match the same cell, so order doesn't matter. Take a shortcut and it does: a rule with four green sides and blank corners also matches every inner-corner case, so above the inner-corner rules it hides them. Keep the rules with the most arrows and crosses on top (drag by the handle at the left).

The Default Sprite is drawn when no rule matches. Set it to the full middle tile, and a missing rule shows as a plain square in the middle of an edge.

Step 6: Paint on a Tilemap

Add a Tilemap with GameObject > 2D Object > Tilemap > Rectangular. Open Window > 2D > Tile Palette, create a new palette, and drag the Rule Tile asset into it. Pick it, choose the brush, and paint: each cell picks its tile from the rules and updates its neighbours. Test a single cell, a one-cell line, a ring and an L-shape.

When the Rule Tile goes wrong

The wrong tile in a tight corner

A rule higher in the list matched first, or a corner was left blank where it needed a red X. Walk down the list with the cell's 8 neighbours: the first rule that fits is the one Unity used.

A notch where the terrain bends inward

The set has no inner corners. A 16-tile set can't draw that shape; use a 47-tile set.

Thin lines between tiles

At a tile's border, the graphics card can read a pixel of the tile beside it on the sheet. Check Point (no filter) and Compression None first. Then give tiles room: pack the sprites into a Sprite Atlas (Create > 2D > Sprite Atlas) with padding, or use a sheet whose tiles have their edge pixels repeated outward (edge extrusion) and slice it with Offset and Padding. If the lines appear only while the camera moves, add the Pixel Perfect Camera component.

Two terrains don't join

"This" means the same Rule Tile, so grass treats a dirt Rule Tile like an empty cell. Put each terrain on its own Tilemap, the lower one filled underneath.

The fast way: the tile sheet in seconds

The Autotile Builder does the drawing, in your browser:

  1. Open a template 3 tiles tall: a plain 3x3 island is enough, or a compact 2x3, with tiles from 8 to 128 px.
  2. It builds the 47-tile blob set from your template's pieces, inner corners included.
  3. Its seam check paints a random map and names the piece of your template to fix where two tiles don't meet.
  4. Save the atlas as a PNG with a JSON file.

It has no Unity-specific export, and Unity doesn't need one: you slice the PNG as in Step 2, and the JSON gives you the rules, with each tile's index, place on the sheet and true or false for each neighbour. The Step 4 example, on 16 px tiles:

{"index": 4, "mask": 7, "col": 4, "row": 0, "x": 64, "y": 0, "N": true, "NE": true, "E": true, "SE": false, "S": false, "SW": false, "W": false, "NW": false}

True is a green arrow, false a red X, except a false corner beside a false side, which stays blank. Tile 4 is the sprite sheet_4 after slicing, and the last tile, index 46, is the full middle tile for the Default Sprite.

The free demo saves exactly this. In its own words, it "saves the Blob 47 atlas (PNG + JSON) for one terrain". The full edition adds the Sides 16 set, 2 or 3 animation frames (a rule's Output set to Animation), several terrains in one atlas, and gaps with edge extrusion, whose margin and spacing in the JSON go straight into Offset and Padding. It also writes Godot 4, Tiled and RPG Maker files.

Your game, looking finished

Every Gridwright asset pack, made to fit together, and all 44 tools for the fiddly work, with every new release, for $17 a month. Try it in your own game first: 3 days for $1 with every tool and up to 10 packs. Cancel any time.

Start: 3 days for $1 See everything it includes

Build your next terrain

Open the Autotile Builder demo, load your template or a sample, check the seams, and save the 47-tile sheet and its JSON for your Rule Tile. The full tool is one of Gridwright's 44 tools, and 150 asset packs come with it.

Your game, looking finished

Every Gridwright asset pack, made to fit together, and all 44 tools for the fiddly work, with every new release, for $17 a month. Try it in your own game first: 3 days for $1 with every tool and up to 10 packs. Cancel any time.

Start: 3 days for $1 See everything it includes