Setting up the grid
Create a new empty gameobject, and add the ‘GridSquare’ script.
If choosing this way, you will need to link up a gridCell prefab from /Prefabs/GridCells if in single-cell mode,
or apply a ‘Simple’ material from /Materials/Grid if in simple mode.
You also have some choices of Lines or Points as well.
Feel free to play around with the initial settings to align the grid, select height, width and cellsize.
The grid mode is mostly game dependent on your style, complexity and your final output device. Simple is the best to start off with to get the basic idea of usage.
You can choose to save your grid using the Prefab SaveGridBtn and load it using the LoadGridBtn. Do not forget to drag in your grid to button and select the GridSquare component and then either SaveGrid or LoadGrid.
You can also create a grid full of already placed objects on load called a PreConfiguration. Run the game, place some objects and hit Create Configuration. This will save the grid, and its objects to file, and also provide you with a screenshot from the camera in your game.
Adding other components
If you are not using the autoCellBlock feature(removes cells depending on certain factors) please continue. Otherwise please follow the documentation on how to set this up.
If you want to use autoCellBlock in your project, it will take seconds to set up when you understand how it works. Please refer to setting up autocellblock to use this. If you choose to try this on your own, you may end up with no cells being created at runtime.
Create a new empty gameobject, and add the ‘GridSelector’ script. You will need to link up the mesh, found in /Meshes/GridSelectors > on the fbx and drag the mesh to meshfilter. You will also need the selector materials, all found in /Materials/GridSelector.
Now you should be able to select the grid, and move around, hazaah.
For placing objects, two components are required. One for creating the actual object, and one for selecting what to build and passing the object to the gridSelector. Create an empty gameobject and place the ‘ObjectPlacer’ script on it, few options to play with here, such as a build timers, try adding a build timer canvas from the prefabs folder under Building Time Settings.
You can copy the buttons from my Demo scene, or simply create a new button, and add the ‘SelectObject’ script to it. This script requires a couple of things, a prefab of an object you want to build on the grid, Move On Points (whether the object will move on the center of the grid cells or the grid points) and the actual cells that this object will take up. This should directly link to your objects physical size for best results.
This will then pass an object to the gridselector when clicking on the SelectObject button, and then when clicking with the left mouse button, passes the object to the ObjectPlacer to build the object.
Feel free to add any visual element under the button to represent your building.
Hopefully now, you can click the button, and build on the grid, great!
For removing objects, create another button, this time add the ‘RemoveMode’ script on it. Drag the ObjectRemover from /Prefabs into your scene. Or create an empty gameObject, and place the ‘ObjectRemover’ script on it. Add the invalidMaterial from /Material/GridSelector.
That’s it! Hit play and you should be able to move, click on an object and place it down on the grid.
You can also hit the removeMode button to highlight and delete objects.
Both placing and deleting objects is done with the left mouse button and cancelling either is done with either the right mouse button or escape.
There are many things to customise in Grid Builder 2. The best possible way of trying out most of the features is through the demonstration scenes.
Almost every scene uses a differerent combination of objects and grids to show all of the possibilities of Grid Builder 2.