Creating Custom Grid Shapes¶
This section covers how to create a non-uniform, shapeless grid. There are two main approaches:
- Custom Block-Based Grids
- Custom Landscape-Based Grids
The second method isn't a fully custom-shaped grid due to the inherent limitations of landscapes.
Block Based Grids¶
Block based grids refer to those that use individual tile "blocks" as their grid surface.
Steps¶
I'll quickly walk you through the setup process, but if you're using the example project, you can skip this section. You can find the full implementation in the BP_PawnSpawner
actor.
-
Before spawning anything, you'll need to create a base surface. This surface will serve as a temporary reference for tracing. Ensure that this mesh follows the surface preparation procedure for proper grid setup.
-
To spawn the "blocks" into the level, you can use the
GenerateGridLocations()
function provided by theGridManager
. For optimal performance, it’s best to spawn blocks as instances of anInstanced Static Mesh Component
. This approach will help efficiently scale the grid without performance issues.I won’t dive into the full implementation details, as you can refer to the
BP_PawnSpawner
in the example project for that. Just ensure that theGridManager
reference is set properly, and then click the Generate Blocks button to proceed. -
Once your base surface is properly configured, you should see a lot of blocks populated across your level.
-
Next, configure the blocks to follow the surface preparation steps. This involves setting custom depth and adjusting collision responses for the
Instanced Static Mesh
component. -
Once everything is set up, you can fill the grid with your desired content.
Custom Shape¶
Now that you know how to create a uniform Block-Based grid, creating custom grid shapes will be much simpler. The process remains the same, with the only difference being the use of a different base surface. For example, if you use a cut-out plane like this:
You get a grid like this.
Managing Tile Leaks¶
In this picture, you can see that the tile visuals don’t align perfectly with the grid lines. This happens because, by default, the instance scale might be slightly off.
You can easily fix this by lowering the Highlight Scale Multiplier values in BP_GridVisuals
. After making the adjustment, press the Force Reload button in BP_GridManager
to refresh the visuals.
Voila!
Custom Landscape Grids¶
The plugin doesn't fully support custom grids on landscapes yet. To work around this, you can either manually cut out sections of the landscape or restrict tile generation in specific areas. However, selectively removing parts of the grid lines isn't possible at the moment.
Let's go over how to prevent tile generation in certain areas.
Steps¶
-
The process is similar to setting up a standard landscape grid. Follow these steps to prepare your landscape properly.
-
After that, you'll need a blocking mesh to prevent tile generation. Here, I'm using a simple plane—just place it over the area you want to block.
-
Make sure to configure the collision settings so the mesh is detected during tracing. However, do not add the "GridSurface" actor tag.
-
Open
BP_GridManager
and press the Generate Grid button. You’ll notice that the area beneath the plane no longer generates tiles.
Custom Highlight Materials¶
If you absolutely need to remove the grid lines, there's a workaround. This method will eliminate all grid lines entirely.
The trick is to make the tile highlight itself resemble a grid line. You can achieve this by assigning a different texture to the highlight material instance.
Steps¶
-
First set the line opacity to 0 via
BP_GridManager
. -
Locate the desired highlight material instance in
Plugins/MegaGrid Content/Materials/
. -
Assign a different texture, here I'm using an outline texture.
-
Go to
BP_GridVisuals
and enableCustom Highlight Material
and assign the new material instance to the Highlight Material reference. In this case I'm using a square grid, so toSquare Highlight Material
. -
Now simply head to
BP_SaveHandler
and hitSave Grid
and thenLoad Grid
. You'll now have a landscape grid that conforms to any shape.The only disadvantage of this method is that you lose anti-aliasing properties of Zero Aliasing Grid and cannot dynamically make modifications to say, line width or tile color.
Custom Grid Materials¶
While we're discussing custom grids, you can also assign custom post-process (grid lines) materials to the grid if needed. To do so, go to BP_GridVisuals
and enable the Custom Grid Material
option. This allows you to assign your own materials to either the Hex Grid Material or Square Grid Material fields.
Note
If you use your own grid material, you'll lose the Zero Aliasing Grid features.