Naming array elements

Hi there,

I am working on a tile based game. I have the tiles laying out perfectly. The problem is how to name them and then access them again. I have named them as below.

pieces[x,z].name = “p”+x + “p” + z;

so it should be named p1p1, p1p2 etc.

How do I now access these pieces. Like p2p3.x = 50 or something.

Thanks

Will

If you have the array:

var pos = pieces[2, 3].transform.position;
pos.x = 50;
pieces[2, 3].transform.position = pos;

If you want to use GameObject.Find (slow):

var pos = GameObject.Find("p2p3").transform.position;
pos.x = 50;
pieces[2, 3].transform.position = pos;