- Home /
Question by
siddharth3322 · May 11, 2014 at 03:46 PM ·
arrayvector3unity4.3
Initialize Vector3 2 Dimensional Array
I want to create 2 dimensional Vector3 array. I used following way but can't able to find correct way to create it.
public static class AdhocStorage{
public static Vector3 [,] CELL_POSITION_PORTRAIT = {
{new Vector3(-5.7f, 7.1f, -3.0f),new Vector3(-4.3f, 7.1f, -3.0f),new Vector3(-2.8f, 7.1f, -3.0f),new Vector3(-1.4f, 7.1f, -3.0f),new Vector3(0.0f, 7.1f, -3.0f),new Vector3(1.5f, 7.1f, -3.0f),new Vector3(2.9f, 7.1f, -3.0f),new Vector3(4.3f, 7.1f, -3.0f),new Vector3(5.7f, 7.1, -3.0f)},
{new Vector3(-5.7f, 5.7f, -3.0f),new Vector3(-4.3f, 5.7f, -3.0f),new Vector3(-2.8f, 5.7f, -3.0f),new Vector3(-1.4f, 5.7f, -3.0f),new Vector3(0.0f, 5.7f, -3.0f),new Vector3(1.5f, 5.7f, -3.0f),new Vector3(2.9f, 5.7f, -3.0f),new Vector3(4.3f, 5.7f, -3.0f),new Vector3(5.7f, 5.7, -3.0f)},
{new Vector3(-5.7f, 4.3f, -3.0f),new Vector3(-4.3f, 4.3f, -3.0f),new Vector3(-2.8f, 4.3f, -3.0f),new Vector3(-1.4f, 4.3f, -3.0f),new Vector3(0.0f, 4.3f, -3.0f),new Vector3(1.5f, 4.3f, -3.0f),new Vector3(2.9f, 4.3f, -3.0f),new Vector3(4.3f, 4.3f, -3.0f),new Vector3(5.7f, 4.3, -3.0f)},
{new Vector3(-5.7f, 2.9f, -3.0f),new Vector3(-4.3f, 2.9f, -3.0f),new Vector3(-2.8f, 2.9f, -3.0f),new Vector3(-1.4f, 2.9f, -3.0f),new Vector3(0.0f, 2.9f, -3.0f),new Vector3(1.5f, 2.9f, -3.0f),new Vector3(2.9f, 2.9f, -3.0f),new Vector3(4.3f, 2.9f, -3.0f),new Vector3(5.7f, 2.9, -3.0f)},
{new Vector3(-5.7f, 1.5f, -3.0f),new Vector3(-4.3f, 1.5f, -3.0f),new Vector3(-2.8f, 1.5f, -3.0f),new Vector3(-1.4f, 1.5f, -3.0f),new Vector3(0.0f, 1.5f, -3.0f),new Vector3(1.5f, 1.5f, -3.0f),new Vector3(2.9f, 1.5f, -3.0f),new Vector3(4.3f, 1.5f, -3.0f),new Vector3(5.7f, 1.5, -3.0f)},
{new Vector3(-5.7f, 0.1f, -3.0f),new Vector3(-4.3f, 0.1f, -3.0f),new Vector3(-2.8f, 0.1f, -3.0f),new Vector3(-1.4f, 0.1f, -3.0f),new Vector3(0.0f, 0.1f, -3.0f),new Vector3(1.5f, 0.1f, -3.0f),new Vector3(2.9f, 0.1f, -3.0f),new Vector3(4.3f, 0.1f, -3.0f),new Vector3(5.7f, 0.1, -3.0f)},
{new Vector3(-5.7f, -1.4f, -3.0f),new Vector3(-4.3f, -1.4f, -3.0f),new Vector3(-2.8f, -1.4f, -3.0f),new Vector3(-1.4f, -1.4f, -3.0f),new Vector3(0.0f, -1.4f, -3.0f),new Vector3(1.5f, -1.4f, -3.0f),new Vector3(2.9f, -1.4f, -3.0f),new Vector3(4.3f, -1.4f, -3.0f),new Vector3(5.7f, -1.4f, -3.0f)},
{new Vector3(-5.7f, -2.8f, -3.0f),new Vector3(-4.3f, -2.8f, -3.0f),new Vector3(-2.8f, -2.8f, -3.0f),new Vector3(-1.4f, -2.8f, -3.0f),new Vector3(0.0f, -2.8f, -3.0f),new Vector3(1.5f, -2.8f, -3.0f),new Vector3(2.9f, -2.8f, -3.0f),new Vector3(4.3f, -2.8f, -3.0f),new Vector3(5.7f, -2.8f, -3.0f)},
{new Vector3(-5.7f, -4.2f, -3.0f),new Vector3(-4.3f, -4.2f, -3.0f),new Vector3(-2.8f, -4.2f, -3.0f),new Vector3(-1.4f, -4.2f, -3.0f),new Vector3(0.0f, -4.2f, -3.0f),new Vector3(1.5f, -4.2f, -3.0f),new Vector3(2.9f, -4.2f, -3.0f),new Vector3(4.3f, -4.2f, -3.0f),new Vector3(5.7f, -4.2f, -3.0f)}
} ;
}
Unity gives me following error.
Please help me to solve this problem.
screenshot 2014-05-11 21.15.33.png
(47.7 kB)
Comment
Best Answer
Answer by Deign · May 11, 2014 at 03:48 PM
If you look at the last vectors in the first 6 rows, you did not label the y values as floats.
You are absolutely right and sorry for my silly mistake.
Your answer
![](https://koobas.hobune.stream/wayback/20220613144804im_/https://answers.unity.com/themes/thub/images/avi.jpg)