The problem isn’t the array actually, the problem is finding a solution to my troubles really. Let me try and explain what I’m trying to do. First, I’m setting variables.
public var objScout1:GameObject;
public var objScout2:GameObject;
public var objScout3:GameObject;
I also make a built-in array for gameobjects.
public var wave1:GameObject[];
and in the start function I add these gameobjects to the array.
function start(){
wave1 = new GameObject[3];
wave1[0] = objScout1;
wave1[1] = objScout2;
wave1[2] = objScout3;
}
Elsewhere I’m instantiating each of these by use of random number,
function selection(b){
//b = random number based on how many objects are in the array
var enemy = Instantiate(wave1**, Vector3(transform.position.x,Random.Range(- 14,14),transform.position.z), transform.rotation);**
wave1.RemoveAt(b);
}
This function takes a random number, instantiates the object and then what I would like it to do after that is, remove that same object from the array. The problem is, which I just found out a minute ago- you cannot remove objects from a built-in array because these arrays have a fixed size.
I have looked around and I found another method in which you could add gameobjects to an arraylist, the problem with that for me was that the length of the array would always came back null. Is that normal? Can anyone possibly give me some insight? Thank you.