Skip to content

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.

alt text

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.

alt text

  1. 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.

    alt text

  2. To spawn the "blocks" into the level, you can use the GenerateGridLocations() function provided by the GridManager. For optimal performance, it’s best to spawn blocks as instances of an Instanced Static Mesh Component. This approach will help efficiently scale the grid without performance issues.

    alt text

    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 the GridManager reference is set properly, and then click the Generate Blocks button to proceed.

    alt text

  3. Once your base surface is properly configured, you should see a lot of blocks populated across your level.

    alt text

  4. 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.

    alt text

  5. Once everything is set up, you can fill the grid with your desired content.

    alt text

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:

alt text

You get a grid like this.

alt text

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.

alt text

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. alt text

alt text

Voila!

alt text

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

  1. The process is similar to setting up a standard landscape grid. Follow these steps to prepare your landscape properly.

  2. 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.

    alt text

  3. Make sure to configure the collision settings so the mesh is detected during tracing. However, do not add the "GridSurface" actor tag.

    alt text

  4. Open BP_GridManager and press the Generate Grid button. You’ll notice that the area beneath the plane no longer generates tiles.

    alt text

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

  1. First set the line opacity to 0 via BP_GridManager.

    alt text

  2. Locate the desired highlight material instance in Plugins/MegaGrid Content/Materials/.

    alt text

  3. Assign a different texture, here I'm using an outline texture.

    alt text

  4. Go to BP_GridVisuals and enable Custom Highlight Material and assign the new material instance to the Highlight Material reference. In this case I'm using a square grid, so to Square Highlight Material.

    alt text

    alt text

  5. Now simply head to BP_SaveHandler and hit Save Grid and then Load Grid. You'll now have a landscape grid that conforms to any shape.

    alt text

    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.

alt text