Skip to content

LoopGrid2D

Loop through positions in a 2D grid and store the current cell as a world position.

Use this to place or process objects in rows and columns without manually calculating each position.

Add actions after this action to run for each grid cell.

Parameters

Parameter Description
X Count Number of columns in the grid.
Y Count Number of rows in the grid.
Origin The starting reference point for the grid in world space.
Plane The plane to project the grid onto: XY, XZ, or YZ.
Anchor How the grid is aligned around the origin, for example Center, TopLeft, or BottomCenter.
Padding X Extra width added across the full grid span.
Padding Y Extra height added across the full grid span.
Fit How spacing is calculated: FixedSpacing, FitLength, or RelativeSpacing.
X Spacing Spacing between columns when Fit is set to FixedSpacing.
Y Spacing Spacing between rows when Fit is set to FixedSpacing.
X Total Length Total width of the grid when Fit is set to FitLength.
Y Total Length Total height of the grid when Fit is set to FitLength.
X Factor Multiplier for Cell Size X when Fit is set to RelativeSpacing.
Y Factor Multiplier for Cell Size Y when Fit is set to RelativeSpacing.
Cell Size X Optional cell width used with RelativeSpacing.
Cell Size Y Optional cell height used with RelativeSpacing.
Store Position Stores the computed world position for the current grid cell.
Store X Index Stores the current column index.
Store Y Index Stores the current row index.

Details

LoopGrid2D loops through the grid one cell at a time. On each pass it calculates a position and stores it in Store Position, so the next actions in the state can spawn an object, move something into place, or run any other logic for that cell.

The loop moves left to right across each row, then continues to the next row. Store X Index gives you the current column, and Store Y Index gives you the current row.

The Plane setting controls which axes are used:

  • XY places the grid on a 2D-style plane.
  • XZ places the grid flat on the ground.
  • YZ places the grid on a vertical wall-like plane.

The Anchor setting controls how the grid is positioned around Origin. For example, Center keeps the whole grid centered on the origin, while TopLeft starts the grid from that corner.

Fit changes how spacing is worked out:

  • FixedSpacing uses the exact X Spacing and Y Spacing values.
  • FitLength spreads the cells across a total width and height.
  • RelativeSpacing multiplies the cell size by a spacing factor.

Examples

  • Spawn a 5 by 3 group of prefabs on the XZ plane and use Store Position as the spawn point.
  • Build a tile layout in XY space and use Store X Index and Store Y Index to choose different tile types.
  • Center a grid of objects around a marker by setting Anchor to Center and Origin to the marker position.