- Home /
Question by
MileSplit · Feb 12, 2013 at 11:25 PM ·
javascriptarray
Help with Array script
So, in runtime, i get the error. Array index is out of range. and the action does not work.
however, the line above is
cubeMap[curRow,curCol] = Instantiate (baseBlock, Vector3(curRow, 0, curCol), Quaternion.identity);
and that works.
but then right under it,
cubeMap[curRow,curCol].renderer.material.mainTexture = normGrass;
And nothing happens :(
i have assigned normGrass in the inspector.
Comment
Best Answer
Answer by hoy_smallfry · Feb 12, 2013 at 11:59 PM
"Array index is out of range" is an very common error that happens in most programming languages, usually when you are trying to access an array element at an index that just doesn't exist.
For example:
var myCars = [123, 435, "BMW"];
print(myCars[10]);
This will give you an array out of bounds error.
I suggest you print out the values of curRow and curCol before those statements so that you know what value is causing the problem.