- Home /
Question by
mitaywalle · Jul 09, 2013 at 12:57 PM ·
arrayboolean
bool multi-dem array out of range
XCount=4;YCount=4;ZCount=4;
in MultiDem.cs I wrote:
public static bool[,,] BoolArray (int a, int b, int c) {
return new bool[a,b,c];
}
log: IndexOutOfRangeException: Array index is out of range. (wrapper managed-to-managed) object:ElementAddr (object,int,int,int) spawnWalls.Start () (at Assets/Zanzarah_2/Map Generator/spawnWalls.js:16)
var XCount:int ;
var YCount:int ;
var ZCount:int ;
private var t1:int;
private var t2:int;
private var t3:int;
function Start()
{
var CkBk = MultiDim.BoolArray(XCount+2, YCount+2, ZCount+2); //проверка наличия блока CheckBlock
for (t1=1;XCount;t1++)
{
for (t2=1;YCount;t2++)
{
for (t3=1;ZCount;t3++)
{
CkBk[t1,t2,t3]=false;
}
}
};
CkBk[1,1,1]=true;
Debug.Log("CkBk[1,1,1]= " + CkBk[1,1,1] + "CkBk[1,2,1]= " + CkBk[1,2,1]);
}
Comment
Best Answer
Answer by robertbu · Jul 09, 2013 at 01:03 PM
Your format of your 'for()' loop is off. Plus arrays are zero based, so you are not initialize all the elements. Try using these for your 'for()' loops.
for (t1=0; t1 < XCount+2; t1++)
and
for (t2=0; t2 < YCount+2; t2++)
and
for (t3=0; t3 < ZCount+2; t3++)
oy, there's error in syntax, but thanx a lot for fast answer!!!
Your answer
Follow this Question
Related Questions
How to circumvent this strange boolean array behaviour? 1 Answer
boolean issue 1 Answer
How do i declare a Boolean Array? 2 Answers