I create a grid with neutral boxes with:
public class GridManager : MonoBehaviour
{
public float x_Start, y_Start;
public int columnLength, rowLength;
public float x_Space, ySpace;
public GameObject neutralBoxGrid;
//Create a Grid with the neutral Box
void Start()
{
if (neutralBoxGrid == null)
neutralBoxGrid = GameObject.FindGameObjectWithTag("neutral");
for (int i = 0; i < columnLength * rowLength; i++)
{
Instantiate(neutralBoxGrid, new Vector3(x_Start + (x_Space * (i % columnLength)), y_Start + (-ySpace * (i / columnLength))), Quaternion.identity);
}
}
That gives me for example a grid 2x2 with 4 cloned neutralBoxes
I like to replace randomly every x seconds 1 of the cloned boxes with a prefab of the resources folder
In my GameLogicScript i get the boxes with:
//Make sure the boxes are in
blackBox = Resources.Load("BoxBlack") as GameObject;
blueBox = Resources.Load("BoxBlue") as GameObject;
greenBox = Resources.Load("BoxGreen") as GameObject;
How can i choose a random cloned object, and how do i replace it with 1 prefab of the resource folder every x seconds?
For a start i created a tagsArray with my boxesPrefabs of the resource folder:
int randomIndex = Random.Range(0, 7);
string randomTag = tagsArray[randomIndex];
pointObject = GameObject.FindWithTag(randomTag);
Debug.Log("I found" + pointObject);
pointObject = pointObjectCount;