I have a grass and dirt texture. No matter what the clones are all grass or all dirt. How do I go about having both textures randomly for the clones.
This is what I have tried when it is all grass or dirt.
public GameObject tile;
Texture2D[] textures = new Texture2D[2];
public Texture2D grass;
public Texture2D dirt;
// Use this for initialization
void Start () {
textures[0] = grass;
textures[1] = dirt;
tile.renderer.material.mainTexture = textures[Random.Range(0,1)];
Generation();
}
void Generation() {
for(int x = 0; x < 30; x++){
for(int y = 0; y < 2; y++) {
for(int z = 0; z < 30; z++) {
Instantiate(tile, new Vector3(x*1,y*Random.Range(0,2),z*1), Quaternion.identity);
}
It’s important to ask yourself: how many times do you want each of these steps to happen? Right now, you’re only randomizing textures once. If you want to do so more than once, why isn’t it done inside your spawn loop?