- Home /
BCE0048: Type 'boolean' does not support slicing.
Here is all of the code I have in the script in question:
#pragma strict
var grid = new boolean[0,0];
function Start () {
var terrainSize = GetComponent(Terrain).terrainData.size;
grid = new boolean[terrainSize.x, terrainSize.z];
}
function getGrid (x, y) {
return grid[x][y];
}
function setGrid (x, y, aValue) {
grid[x][y] = aValue;
return null;
}
The problems I am having are: 1: I can't find a way of initialising grid within 'Start' and also making it 'global'. ie, accessable in setGrid and getGrid, not in other scripts.
2: Using what I am at the moment causes this error:
Assets/Scripts/TerrainManagement.js(15,20): BCE0048: Type 'boolean' does not support slicing.
and another for the second grid[x][y]
Javascript novice, sorry for silly questions.
You can try grid[x,y]
as showed here http://answers.unity3d.com/questions/11963/how-to-create-multidimensional-arrays-in-javascrip.html
Answer by rutter · Jul 30, 2014 at 10:34 PM
grid[x][y]
should be grid[x,y]
for the type of array you're using.
.NET distinguishes between "multi-dimensional" and "jagged" arrays. You've declared a multi-dimensional array, but the syntax you use to access it is what you'd use for a jagged array.
If you'd like to know more, these explain a bit and might give clues for further reading:
Your answer
![](https://koobas.hobune.stream/wayback/20220613155428im_/https://answers.unity.com/themes/thub/images/avi.jpg)