void FixedUpdate() { if (currentSpawnTime == 0) { GameObject enemy = new GameObject(); EnemyObject eo = enemy.AddComponent <EnemyObject>(); int rndIndex = rnd.Next(0, currentWave.enemies.Count); Debug.Log(rndIndex); Enemy enemyType = currentWave.enemies[rndIndex]; eo.Load(enemyType); eo.gm = this; enemy.transform.position = Random.insideUnitSphere * 3; enemy.GetComponent <Rigidbody2D>().rotation = Random.Range(1, 359); enemy.name = eo.enemyType.name; aliveEnemies.Add(enemy); currentSpawnTime = spawnTime; } else { currentSpawnTime--; } }