Easiest way to have a large number of variables

I am looking to have a lot of objects in my game, and I do not know how I should have all of those coordinates stored into variables, would the best option be to create and array of Vector3 coordinates or is there a faster, less memory consuming way to do this? thanks!

You should use a Vector3 array. It’s a piece of cake for any game engine - every game object created occupies hundreds of bytes, while each Vector3 element occupies only 12 bytes. It won’t even scratch the available memory.

You can use built in arrays, but you must know the array length beforehand. I did it once: I had a main control script, and a few instructions in each trackeable object’s script to count itself and fill the array.

This is the control script (Control.js)

static var numObjects = 0; // objects will count themselves here
static var positions: Vector3[]; // array is actually allocated in Start

function Start(){
  positions = new Vector3[numObjects]; // at Start all objects were counted
}

In the object script, the object counts itself in Awake, and fills its position in Update only once:

var myNum: int; // object ID number
private var setPos = true; // tells the object to save its position in the array

function Awake(){
  myNum = Control.numObjects; // object records its ID number
  Control.numObjects++; // and increments object count
}

function Update(){
  if (setPos){ // need to set position?
    Control.positions[myNum] = transform.position;
    setPos = false; // do it only once in life!
  }
  ...
}