Stupid industries - Selectable grid

The selectable grid plugin contains :

  • A base class that allows you to easily create a grid of the same static mesh (using instanced static mesh)

  • An easy way to create a border around the grid

  • Dynamically link an object instance to a grid cell (supports network replication)

  • Use the Gameplay ability targeting system to do grid selection (single cell and rectangle selection)

Demonstration video : https://youtu.be/BGew9bgf8zE

Discord : https://discord.com/channels/1371516167478579200/1371516303382155355

Grid base class

The main thing this plugin provides is a base class that allows to easily create a grid where each cell is represented by a static mesh (the same mesh for all cells). Things that can be configured :

  • Width and height of the grid

  • Static mesh to use for the cells

  • Where the center of the mesh is in order to center the mesh in the cell

  • A transform to apply to each mesh on top of its location on the grid

Grid border

This Actor exposes a function that will emit a struct for each of the cells around the perimeter of the grid.

The structure contains the index of the cell, the transform that you can use to place a wall or a corner as well as a boolean indicating if this index is a corner.

This allows you to easily build a border around the grid by iterating through the structures and spawning either a wall or a corner with the correct transform.

Object linking

The interface that the grid base class exposes also allows you to associate and object with a grid cell. This allows you to spawn an object at a certain grid index, associate it with that index and later check whether this index is "occupied" and get a reference to the object occupying the cell.

This object linking supports replication, meaning that you can modify the object association on the server and it will replicated to the clients (as long as the objects themselves are also replicated of course).

Selection

The last thing this plugin provides is a way to select one or multiple grid cells by using a Gameplay ability target actor. This allows you to select either a single cell or a to do rectangle selection on the grid. The targeting actor support start, stop and cancel events while targeting and will emit a specific TargetData structure when the selection is confirmed. This structure contains the start location, end location as well as the grid actor that was interacted with.

This allows client side selection while using the selection data on the server.

The last part of the plugin is a specific class and interface for the targeting reticle. The interface will emit an onselectionchanged event each time the start and end indices of the selection change. This allows the reticle to visually represent all the cells that are selected in real time.