I have a lot of cubes in my scene, which all of them is named a number.
#pragma strict
var amount = 25;
var objectNumber = 0;
var object : GameObject;
function Start () {
objectNumber = Random.Range(1, amount);
object = gameObject.Find(objectNumber);
}
I want to randomly select one of the cubes by using random.range, and then select the choosen number, which one of the cubes has and put it in the object variable.
The problem is, that the name of the cubes are strings, and i apparantly can’t choose them with a int.
Is there a way i can do this?
I don’t want to put each of them in a array. To much time since i will be doing it with a lot of cubes.