My code creates tiles of terrains on start, I wanna use SetNeighbors to connect each Instantiated terrain to its neighbors. here is my code:
var terrainMember:Transform;
var terrainRow:int=20;
var terrainCol:int=20;
private var terrainTile:Terrain[] = new Terrain[400];
function Start () {
for (var row=1;row<terrainRow;row++){
var newRow = 100*(row-1);
for(var col=1;col<terrainCol;col++){
var arrayPosition = col-1+(terrainRow*(row-1));
var newCol=100*(col-1);
terrainTile[arrayPosition] = Instantiate(terrainMember,Vector3(newRow,0,newCol),Quaternion.identity);
}
}
}
The problem is on start it only creates one terrain and gives me an error: "Cannot cast from source type to destination type."
I need to have this array so that i can easily assign each terrain its neighbors. Otherwise I tried doing the same thing using a transform array and it just works fine. Any clue? thanks,