Unity cannot find component of an object in an array.

The Code:

    private var resetObjects=new Array(11);
    private var resetPositions=new Vector3[11];
    function Awake(){
     var a=0;
     for(var obj in resetObjects)
     resetPositions[a++]=obj.transform.position; //Error

Console Error:
Assets/PlayerController.js(16,41): BCE0019: ‘transform’ is not a member of ‘Object’.

What is the Error and how to solve it?

Thank You in advance.

You can use an Array of Game Objects (GameObject) instead of using Array() or cast the type of obj to GameObject

You should use a List. which can be dynamically sized, is strongly typed and supports the same access format.

 import System.Collections.Generic;


   var resetObjects = new List.<GameObject>();

Array is really not a good idea - but if you insist you can cast the value like this

   resetPositions[a++] = (obj as GameObject).transform.position;