I have a double bracket, public array that when the value of [0][6] of the bracket gets changed to “1”, the [1][6] value immediately gets changed to “1” as well and I have no idea why. Here is the code.
This is the array being created in the constructor of my “engine” script.
public float[][] Frogs;
This is the code when the array is being created and have values added to the brackets.
Frogs = new float[2][];
float[] frogInfo = new float[10];
frogInfo[0] = 0;
frogInfo[1] = 0;
frogInfo[2] = 0;
frogInfo[3] = 0;
frogInfo[4] = 0;
frogInfo[5] = 0;
frogInfo[6] = 0;
frogInfo[7] = 0;
frogInfo[8] = 0;
frogInfo[9] = 0;
Frogs[0] = frogInfo;
Frogs[1] = frogInfo;
Then, from a completely different script, I try to change the value of[0][6] to 1, but as soon as I try, the value of [1][6] changes as well. I even checked it in the log and it changes with it.
Debug.Log(froggyengine.Frogs[1][6]);
froggyengine.Frogs[0][6] = 1;
Debug.Log(froggyengine.Frogs[1][6]);
Can anyone answer why?