Random.Range() returns a float value, but you are using it as an array index (which is an int value). Maybe that's the problem? Try rounding the output of random:
var spawnpoint : Transform = spawnpoints[Mathf.RoundToInt(Random.Range(0, spawpoints.length))].transform;
Does it work?
↧