Hey, i’ve been working on a script that spawns a lot of different rocks; each different rock is a prefab, and they are all placed in an array variable by exposing it to the editor, like so: var all_the_rocks: Transform[];
However when i try to Instantiate an object by using: Instantiate(all_the_rocks[Random.Value * all_the_rocks.length], postion, rotation); the console erratically tells me that the array index is out of range.
As far as i can see, there’s NO WAY the index could be out of range, but at least half the time unity comes to this part of the code it throws up the same error.
Thank you in advance, if i haven’t been clear please tell me and i’ll try to explain myself better.