I’m tryng to initialize an array, but so far no luck.
var Active = new int [10];
function Start()
{
for(var ix = 0; ix < 10; ix ++ )
{
Active [ix] = 0;
}
}
That piece of code, gives me an error of “IndexOutOfRangeException : Array index is out of range.”
If i make a Active.Length , it returns me a lenght of 1.
What am i doing wrong ?
thanks,
That code should work as written. The only thing that I can think that might affect it, is if you have modified the array by hand in the inspector - since it’s a public var, it’ll show up and be editable in the inspector, which overrides any values assigned to it in your script when you declare it.