ok so i have mapNodes[x,z] on a grid the GameObject node[x,z] stores the MapNode[x,z] script . This works however it is extremly slow, why?
public void findAllAdjacentNodes(){
for (int x = 0 ; x < mapWidth ; x++)
{
for (int z = 0 ; z< mapHeight ; z++)
{
try{
mapNodes[x,z].northNode = mapNodes[x,z+1];
}
catch{}
try{
mapNodes[x,z].southNode = mapNodes[x,z-1];
}
catch{}
try{
mapNodes[x,z].eastNode = mapNodes[x+1,z];
}
catch{}
try{
mapNodes[x,z].westNode = mapNodes[x-1,z];
} catch{}
}
}
}