I have a game were a grid will spawn and i need the colors of each cube on the grid to randomize but everyone of them is a clone, currently when i press start simulation the cubes will go on flashing or will be all white or black (occasionally they will be half and half like their supposed to) **what am i doing wrong?**
code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class Wall : MonoBehaviour {
//get random
System.Random rdn;
//clone temp random
private int _tempRnd;
//textures
public Texture2D White;
public Texture2D Black;
void Start () {
//pick random and then input into clone temp random
rdn = new System.Random();
_tempRnd = rdn.Next(1, 3);
// send log for viewing
Debug.Log(_tempRnd);
//pick the number anc choose
if (_tempRnd == 1)
{
GetComponent().material.mainTexture = White;
}
else
{
GetComponent().material.mainTexture = Black;
}
}
}
↧