(To Learn more about Grids, see the documentation page for Grids).
[dropcap]1[/dropcap] Configure the Camera. Set main Camera to orthographic, set the size, and choose a background color.
[dropcap]2[/dropcap] Create the grid. Create an empty game object and add a Rect Tile Grid Builder to it. Add a cell prefab that will be used as the background for each cell of the grid. Set the shape and size of the grid.
[dropcap]3[/dropcap] Configure the Neighbor Setup. This affects which squares are considered neighbors, and affects pathfinding and some line algorithms. Main is for orthogonal neighbors, Diagonal is for diagonal neighbors, and Main and Orthogonal is for both.
[dropcap]4[/dropcap] Set up a checkerboard coloring:
- Tick Use Color.
- Leave only two colors and set them to the two colors you want.
- Set the color function to x0 = 2, x1 = 1 and y1 = 1 for a checkerboard pattern. For other patterns, see What are Grid Colorings.
[dropcap]5[/dropcap]Tick Interactive.This will allow mouse input, and click Build Grid. The grid should now appear in the editor.
[dropcap]6[/dropcap] Add pieces to the board:
- Add Grid Game Manager script component (Grid Game Rules will automatically be added).
- Add the logical piece prefabs to the Pieces field in Grid Game Rules.
- Setup the Initial Pieces in Grid Game Manager.
- Click Build Grid to have the pieces added.
[infobox]Note that the pieces will disappear when you run the game. This is intended behavior (the pieces are added at runtime during another step not covered in this example). See this question for more information: https://gamelogic.quandora.com/abstract_strategy/q/61c38319f013435d91c2a0a584b2a75e/SetupGridAndBoard-unitypackage-r [/infobox]
To check out this example:
- Import Abstract Strategy in a new project.
- Import the package below into the same project.
- Open the SetupGridAndBoard scene.