unity-game-layout
Unity Game Layout (coordinate systems & boards)
Most "the board looks broken / pieces float off their tiles / taps hit the wrong cell" bugs are ONE bug wearing different masks: the logical grid, the rendered grid, the placement math, and the picking math each compute "where is cell (x,y)" slightly differently. Fix that and all the masks fall off.
The one rule: a single source of truth for the grid
Define exactly one function CellToWorld(cell) -> worldCenter and derive EVERYTHING from it:
the drawn grid lines, every piece's position, and the inverse used for input. Never hand-place the grid
lines with one set of numbers and the pieces with another — that divergence is the #1 cause of
misalignment. If you render a grid AND place pieces, both must call the same mapping.
Validation gate (do this BEFORE building gameplay on the board): place a tiny marker dot at
CellToWorld(c)for every cell, render the grid from the same function, screenshot, and confirm each dot sits dead-center in its cell. If they don't coincide, the mapping is wrong — stop and fix it before adding pieces, animation, or input. (This is the layout analogue of the solver-gate: prove the coordinate system before you build on it.)