- Home /
Change an objects Array position dynamiclly in a match 3 game
Hello! I am new to unity and i am trying to make a match 3 game. And now i have a little problem. I stored my Tiles in a 2dimensional array to have their position. I Already made the Match detection and the tile swapping. My problem is: when i match some tiles and destroy them, all the other tiles fall down. Now the whole system doesnt work anymore cause the index of the objects in the array stays the same like before.i have tried to change the tiles back with this script:
Tile tmp = tiles[t1.w,t1.h];
tiles[t1.w,t1.h] =tiles[t2.w,t2.h];
tiles[t2.w,t2.h] = tmp;
Its possible to do this with one or two tiles, but not with all those that fall by the gravity. is there an easier way to sort my Tile-objects in the array so i have Rows and Collumns again?
Sorry for my bad english, i hope you understand my problem. Thanks:)
Comment