Creating a puzzle game style grid.

Hello. I want to set up a gird like this where I can have objects move from one cell to another. I was thinking of using a script to instantiate the cells(so they would form a perfect grid) as a series of empty objects. I would then store the positions of those objects as elements in an array, and when I want to move the object I would just call that cells position(something like transform.position=Cells[0].position). Does this sound like a good idea, or am I overlooking some solution that is more practical. I know this is a vague concept (Im still working out the gameplay myself…I just thought of the basic idea), but any help or advice would be greatly appreciated. Thanks

2 dimensional array is what you would use for a grid and to keep all the data in it.

How would I set up the 2D array?

create a 5x5 array of transforms

private var array2d : Transform[,] = new Transform[5,5];

access the 1,2 element

array2d[1,2].position = Vector3.zero;