- Home /
Question by
IMTRIGGERHAPPY9 · Aug 18, 2011 at 02:48 AM ·
arrayloopgridfor-loop
creating a 2d array for grid (Not been asked i swear)
ok so i have this code. it does its job perfectly, but i need more knowledge to extended it to do what i want
heres the code:
GridFloor.JS
var tilePrefab : Transform;
var FloorArray = new Array();
var nameN : int = 0;
function Start () {
for(var i : int = 0; i < 10; i++){
for( var j : int = 0; j < 10; j++){
Instantiate(tilePrefab, Vector3(i + 5,0, j + 5) ,Quaternion.identity);
FloorArray.Add(tilePrefab.name +nameN);
print(FloorArray);
}
}
}
what i want it to do is create a 2d array one of the arrays being the x coordinate and the other being the y coordinate. i also want each one of the tiles to have another name from the last one.. as you can see with my VAR NAMEN; i was dabbling in it but couldn't make it work. can anybody help me?
Comment
Answer by Eric5h5 · Aug 18, 2011 at 03:40 AM
Just use a 2D Transform array; don't use the Array class.
var floorArray : Transform[,];
that doesn't make much sense to me... what does that do? and how would i implement it?