public GameObject enemyPrefab; // connect this in your editor.
List enemies = new List();
void Start ()
{
// this will call the SpawnEnemy method every 3 seconds.
// if you want to decrease the time don't do this, but call instead SpawnEnemy in Start and then use at the end of SpawnEnemy: Invoke ("SpawnEnemy", seconds);
InvokeRepeating("SpawnEnemy", 3f);
}
void SpawnEnemy ()
{
// enemyPrefab is your EnemySpawer
// instantiate return a copy of the instance. so you have to add everytime another object not the same EnemySpawer
GameObject enemy = Instantiate (enemyPrefab);
enemy.transform.position = new Vector2( x, y );
AddEnemy (enemy);
}
void AddEnemy (GameObject enemy)
{
enemies.Add (enemy);
}