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 :frowning:

i have assigned normGrass in the inspector.

“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.