|
Can someone help me understand what is going on here? Upon lauch, everything works fine and then after about a minute (sometimes longer), i get the error you see in the tittle. Please help, maybe there's something I'm not seing. (ArgumentOutOfRangeException: Argument is out of range. Parameter name: index System.Collections.Generic.List`1[UnityEngine.GameObject].get_Item (Int32 index) Spawnhighway.Update () (at Assets/Scripts/Spawnhighway.cs:26)
(comments are locked)
|
|
To properly use Random.Range, you should always use the current size of the collection (in your case the List). Also make sure that your list is filled with enough values (in your case 8), before the game start. oh my bad didnt check it properly, i saw the doc for float and got hasty =/. deleted my answer.
Jul 06 '12 at 09:10 AM
flamy
Thank you, I've been running the test for about 15 minutes now and it hasn't stopped the game to display the error where as before it would have done so after about a minute.
Jul 06 '12 at 12:37 PM
darksblood
(comments are locked)
|

check out with the if statement u cannot compare gameobject with int so because of that it is displaying index out of range
I've formatted your code for you - please indent it by 4 spaces or 1 tab before pasting, or highlight it and then press the code button after pasting.