The code i have right now only goes until 9 on each X and Y array. what i want to know is how would i continue it ( ill explain more after the code)
var instantiateObject : Transform;
var gridX = 10;
var gridY = 10;
function Start () {
//create two new arrays for the x and y axis
tileArrayY = new ArrayList();
tileArrayX = new ArrayList();
for ( var x = 0; x < gridX; x++){
for (var y = 0; y < gridY; y++){
var myName = Instantiate(instantiateObject, Vector3(x *.5,0,y * .5), Quaternion.identity);
myName.name = "x: " + x + "y: " + y;
// assign each y and each x to the individual arrays
if( y % gridY == 0 ){
tileArrayY.Add(myName.gameObject);
}
if( x % gridX == 0 ){
tileArrayX.Add(myName.gameObject);
}
}
}
// check those arrays
for( var i = 0; i < 20; i++){
print("This is your YArray: " + tileArrayY*); *
_ print("This is your XArray: " + tileArrayX*);_
_ }_
_}_
so what i am getting from this code is:
Xarray:
x:0 y:0
x:1 y:0
x:2 y:0
x:3 y:0
_…_
x:8 y:0
x:9 y:0
Yarray:
x:0 y:0
x:0 y:1
x:0 y:2
x:0 y:3
_…_
x:0 y:8
x:0 y:9
but i want them to do this instead:
Xarray:
x:0 y:0
_…_
x:9 y:0
x:0 y:1
_…*_
x:9 y:1
i hope this makes sense? ask me to clarify if you dont understand it and ill be happy to help you help me
thanks
This is really confusing. What you have now is two arrays with 10 elements each; is that what you actually want, or should it be a bidimensional 10x10 array, thus containing 100 elements and covering completely a rectangular area (from the name tile, that's what I suspect you actually need).
– aldonalettoyes that is what i wanted an multidimensional array, but i couldn't figure out how to put the x's in one and the y's in another. so i decided to go with two seperate arrays instead, but i do need it to be 10x10. so i am restricting it some how?
– IMTRIGGERHAPPY9