can someone please help me how to instantiate an object inside a grid like on the pic and change the object that is instantiating on a set of score ?
,
can please someone help me how can i add a random object on each cell like on the second image.
and then change the object that instantiating on a set of score ? for example on start i have a color tiles and when i reach the 101 the tiles that instantiate will be change on shapes ?
what i would do is to create an empty gameobject for each cell on the board and place them in order. I would name the empty gameobjects cell1, cell2, cell3 …
If I want to place 10 objects randomly at start:
List<int> list = new List<int>();
for (int i=0; i<10; i++){
while (1 == 1){ // this while loop is done to avoid two objects in same cell
float num = Random.range(1,63); // 7 cols by 9 rows is 63 cells
if (!list.Contains(num)){
list.Add(num);
break;
}
}
prefabCell = // here you instantiate the cell prefab (I dont remember the code)
string targetCellName = "cell" + num;
prefabCell.transform.position = Gameobject.find(targetCellName).transform.position;
}
}
btw. is it possible to make a repeating/non ending grid for my game like “piano tiles”? for example on last row of the grid. when it passes the canvas it will add a new row and add objects. please enlighten me