Array Error - Won't return items in array

MissingFieldException: Field 'System.MonoType.enemySet' not found.

is the error I get.

In SpawnEnemies.js:

static var enemySet;

function Start () {
    enemySet = new Array();
}

//I cut out the stuff not pertaining to my problem.

var thisEnemy = Instantiate(enemy, spawnPos.position, Quaternion.identity);
enemySet.Push(thisEnemy);

and then in TowerShoot.js:

var lookAtTarget : Transform;

function Update () {
    if (SpawnEnemies.enemySet.length > 0) {
                //printing the array length shows it increasing as I add enemies.
        for (i = 0; i < SpawnEnemies.enemySet.length; i++) {
                // This is where the error is going off.
                // Whenever I try to get a certain member of the array I get the error
        print(SpawnEnemies.enemySet[0]);
            if (Vector3.Distance(SpawnEnemies.enemySet*.position, transform.position) < Vector3.Distance(lookAtTarget.position, transform.position)){*
 _lookAtTarget = SpawnEnemies.enemySet*;*_
 _*}*_
 _*}*_
 _*transform.LookAt(lookAtTarget, lookAtTarget.up);*_
 _*}*_
_*}*_
_*```*_
_*<p>Am I doing something wrong? I can't figure out why it would have no problem giving me the correct array length but then claim it doesn't exist if I try to get things in the array.</p>*_

1 Answer

1

You should set the type for enemySet, as it is it can't work out what it is from the other script

static var enemySet : Array;