I have this 2D Array which is giving me a Array index is out of range, problem. What is the cause of this problem and how can i solve this ?
EDIT: Yep, sorry about that. I will include what i will want to do here:
So im trying to make jagged array which.
So i have a number of platforms, numOfPlatforms
I want to go through them, and each platform has its Size which is randomXSize.
And now, i want mark a point in each platform which is every 0.5, thats why i made
(randomXSize - 0.5)
But i don't know how many times i will need to do that for so i made
randomXSizeSegments = randomXSize * 2;
To calculate how many 0.5 will be for each randomXSize.
So in other words, If the first platform '0' has a randomXSize of 3
I want the array randomXSizeSegments to be looking like this
randomXSizeSegments[1][0] = 3
randomXSizeSegments[0][1] = 2.5
randomXSizeSegments[0][2] = 2
randomXSizeSegments[0][3] = 1.5
randomXSizeSegments[0][4] = 1
randomXSizeSegments[0][5] = 0.5
randomXSizeSegments[0][6] = 0
And if second platform '1' has a randomXSize of 7
I want the array randomXSizeSegments to be looking like this
randomXSizeSegments[1][0] = 7
randomXSizeSegments[1][1] = 6.5
randomXSizeSegments[1][2] = 6
randomXSizeSegments[1][3] = 5.5
randomXSizeSegments[1][4] = 5
randomXSizeSegments[1][5] = 4.5
randomXSizeSegments[1][6] = 4
randomXSizeSegments[1][7] = 3.5
randomXSizeSegments[1][8] = 3
randomXSizeSegments[1][9] = 2.5
randomXSizeSegments[1][10] = 2
randomXSizeSegments[1][11] = 1.5
randomXSizeSegments[1][12] = 1
randomXSizeSegments[1][13] = 0
void Debugging_One() {
for(int a = 0; a < numOfPlatforms; a = a + 1) {
randomXPosSegments = new int[a][];
randomXSizeSegments = randomXSize * 2;
//Debug.Log(a);
//Debug.Log(randomXSizeSegments);
for(int b = 0; b < randomXSizeSegments; b = b + 1) {
// randomXPosSegments[a][b] = 0;
randomXPosSegments[a] = new int[] {(int)(randomXSize - 0.5)};
//Debug.Log(b);
}
}
}