Add GameObject to an Array.

I’m trying to add Specific game objects and their position to an array so they can be Instantiated afterwards in their positions? I know how to add the gameobjects to an Array but not their positions. Anyone got any clues?

public GameObject[] Objects;
public GameObject Ball;

void Update() [

if(Input.GetKeyDown(KeyCode.Space)) {

Objects.Add(Ball);

}

else if (Input.GetKeyDown(KeyCode.Enter)) {

Instantiate(Objects, transform.position, transform.rotation);

}

}

Well first of all Arrays do not have a .Add function, for that you need a List:

List Documentation

Also you cannot instantiate an entire array or list you will need a for loop to instantiate each object individually.

A list/array for the positions is all you would actually need as the Ball variable is being passed into the Instantiate function every time and will never change.