(To Learn more about Grids, see the documentation page for Grids).1 Configure the Camera. Set main Camera to orthographic, set the size, and choose a background color. 2 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. 3 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. 4 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.
- 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.
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
To check out this example:
- Import Abstract Strategy in a new project.
- Import the package below into the same project.
- Open the SetupGridAndBoard scene.