Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Index Out of Range Exception?

$
0
0
//conditions to check public int[] cause = { 0 //Enemy is at full health , 1 //Enemy health <= 90% , 2 //Enemy health <= 75% , 3 //Enemy health <= 50% , 4 //Enemy ehalth <= 25% , 5 //Owner is at full health , 6 //Owner health <= 90% , 7 //Owner health <= 75% , 8 //Owner health <= 50% , 9 //Owner health <= 25% , 10 //DEFAULT }; //actions to perform public int[] effect = { 0 //Light Attack , 1 //Medium Attack , 2 //Heavy Attack , 3 //Magic: Fire , 4 //Magic: Ice , 5 //Magic: Cure , 6 //Magic: Cura , 7 //Use item , 8 //Unsummon , 9 //UNASSIGNED , 10 //UNNASSIGNED }; // Use this for initialization void Start () { options = new int[][,] //first thrown here. { new int[,] { { cause[9],effect[6] }, { cause[8],effect[6] }, { cause[7],effect[5] }, { cause[4],effect[2] }, { cause[3],effect[3] }, { cause[10],effect[6] }, { cause[2],effect[7] }, { cause[2],effect[8] }, { cause[1],effect[9] }, { cause[0],effect[0] }} }; } The code above is a snippet that is giving me a slight issue. with the variables as is, it throws an ArrayIndexOutofRange error at the line indicated with a comment, and it throws a second wherever i am calling the data. at the moment i am using a test calling of: Debug.Log(options[0][0,0]); //should return 9 here's the interesting part, if i change the 6th cause of options from cause[10] to anything else that i have listed, then i don't get the error.

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>