I’m trying to make a game where tiles get added to the floor continuously but the colour of the tiles are random when added. I’ve done this by Instantiating the selected tiles into the level when they collide into a trigger like this;

```
private int rndnum;
public int i = 2;
private in u = 10;
public GameObject Tile1;
public GameObject Tile2;
public GameObject Tile3;
public GameObject Tile4;
public GameObject Tile5;
private void Start()
{
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
i = i++;
print(i);
{
rndnum = (Random.Range(1, 5));
if (rndnum == 1)
{
Instantiate(Tile1, new Vector3(0, u + -11,i * 27.5f), Quaternion.Euler(new Vector3(20, 0, 0)));
}
if (rndnum == 2)
{
Instantiate(Tile2, new Vector3(0, u + -11, i * 27.5f), Quaternion.Euler(new Vector3(20, 0, 0)));
}
if (rndnum == 3)
{
Instantiate(Tile3, new Vector3(0, u + -11, i * 27.5f), Quaternion.Euler(new Vector3(20, 0, 0)));
}
if (rndnum == 4)
{
Instantiate(Tile4, new Vector3(0, u + -11, i * 27.5f), Quaternion.Euler(new Vector3(20, 0, 0)));
}
if (rndnum == 5)
{
Instantiate(Tile5, new Vector3(0,u + -11, i * 27.5f), Quaternion.Euler(new Vector3(20, 0, 0)));
}
}
}
}
}
```

All of the box colliders have the same script but as the tiles are instantiated the ‘i’ value doesn’t change between one trigger with its script and the next trigger so the tiles just spawn on top of each other.

Edit: Sorry should have mentioned this, the ‘i’ value is used so that the tiles spawn at a new vector right next to each other.