I have an int from another class, and the class is called PlayerScript1, and I am retrieving the int called “gameLevel” to get the current level, where I store it in the int localGameLevel. That data is checked in the animalLevelData1 list, where it scans what animals need to spawn in the scene. Then, I have another called “animalSpeed1” and this is the problem. It stores how fast the animal goes, depending what slot in the list that it is in. The code is animalLevelData1[animalLevelData1[localGameLevel]] because I am trying to retrieve data from another set of data. I keep getting the error: IndexOutOfRangeExeption: Array Index Out of Range. Is it not possible to retrieve data like that? or is there another solution? Any feedback is greatly appreciated. Thanks!
public int[] animalLevelData1;
public int[] animalSpeed1;
private int localGameLevel;
transform.position = new Vector3 (predatorPos.x +=
animalLevelData1[animalLevelData1[localGameLevel]],predatorPos.y,predatorPos.z);
void getLevel()
{
player = GameObject.Find ("Player1");
localGameLevel = player.GetComponent<PlayerScript1> ().gameLevel;
}