Unreal Engine 4 plug-in for square and hex grids and simple A*(Star) pathfinding. An instance of a grid is managed by an Actor that holds an array of the cells (points/nodes) on the grid. There are helper functions in both C++ and Blueprints for you to manipulate the grid, it's cells and your gameplay actors. Made and tested in Unreal Engine 4.27.
- Async grid generation
- Async A* pathfinding
- Non iterative cell validation
- World Location <-> Grid coordinates conversion
- GameplayTag based filtering for cell retrieval
- Cell and Cell Vertex location data
- Grid Movement Component
- Hexagon version
- Common helper cell selection operations (think trace and overlap but for cells, sorta)
- WFC (Wave Function Collapse) base class
- Map importing
- Install plugin to your project's plugin folder and enable it by going to Edit > Plugins. e.g:
MyProject\Plugins\Dn2GameGrids - Add a BoxGridActor to your level or create a blueprint with BoxGridActor as its parent class.
- In the details panel of your placed BoxGridActor or class defaults panel of your blueprint, under the Grid category, check bAutoGenerate, and set the extents or your grid.
- Alternately, you can skip step 3 and use the blueprint node
Update Grid Asyncto build your base grid at runtime.Update Grid Asyncoverwrites the current grid if there is one. - Additionally
Update Grid Async, on completion fires off Blueprint and C++ events with the resulting grid array, grid extents and cell size.
-
Cell: A point or node on the grid with associated 2D coordinates (e.g 4,20). See
Cell Info. -
Cell Address or Address: the 2D coordinates (e.g 7,11) that represent a position on the grid.
-
Cell Info:
FCellInfoStruct that holds the info for the cells on a grid.UpdateGridAsync()populatesTArray<FCellInfo> GridArraywith these. You can findFCellAdress,FGameplayTagContainer, etc held within. -
Cell Tags:
FGameplayTagContainerthat holds theFGameTagsthat are associated with aCell Info. -
Grid Extents: The extents of the grid. A
FIntPoint, X being how many cells wide and Y being how many cells 'tall'. -
Neighbors: Any cells directly next to a given cell. e.g.
GetCellNeighbors()returns cells next to a given cell. -
Cell Size: The size of a cell when calculating its dimensions & location in world space in relation to the
AGridActorBasethat owns it.
| Name | Members | Description |
|---|---|---|
| FCellAddress | int32 X in32 Y |
Coordinates for a cell, X and Y |
| FCellInfo | FCellAddress Address FGameplayTagContainer CellTags |
Used for grid array. Holds info for each cell in the grid array |
| FAStarCellInfo | float H float G float F FCellAddress Address FCellAddress CameFrom |
Used for the A-Star algo |
| FAStarSearchResults | bool bFoundGoal TArray<FCellAddress> Path |
Struct holding the results of AStar search algorithm |
| Name | Type | Description |
|---|---|---|
| bAutoGenerate | bool |
Show a grid preview in editor & generate on BeginPlay |
| CellSize | float |
Size of cells |
| DefaultCellTags | FGameplayTagContainer |
If bAutoGenerate, generate a grid on BeginPlay using these Tags |
| GridArray | TArray<FCellInfo> |
Array holding our grid cells |
| GridMeshComp | UStaticMeshComponent* |
Visual of the grid and trace collisions for world locations <-> grid address conversions |
| GridMat | UMaterial* |
The material we'll make and instance of and use for visual debugging |

