Question by
Jonski · Apr 20, 2016 at 04:50 AM ·
javascriptarraystatic
Static Array JS
I am trying to make a static array that holds an integer in each element, however upon testing, the array seems to be new for each object that accesses it. This is attached to an object, that duplicates of that object access and change.
static var tiles: float[];
function Start() {
tiles = new float[6];
tiles[1] = 1;
Random();
}
function Random() {
i = Random.Range(1, 6);
if (i == 1) {
tiles[1] ++;
} else if (i == 2) {
tiles[2] ++;
print(tiles[2]);
} else if (i == 3) {
tiles[3] ++;
} else if (i == 4) {
tiles[4] ++;
} else if (i == 5) {
tiles[5] ++;
} else if (i == 6) {
tiles[6] ++;
}
}
Comment