public void Spawn() { if (position == null) { position = transform; } foreach (SpawnParameters sp in spawnList) { NodeBehaviour startingNode; if (sp.startingNode != null) { startingNode = sp.startingNode; } else { startingNode = NodeBehaviour.GetClosestFreeSpawnNode(position.position); } GameObject enemyPawn = GameObject.Instantiate(sp.enemyPrefab, startingNode.offsetPosition, Quaternion.identity) as GameObject; startingNode.currentObject = enemyPawn.GetComponent <Targetable>(); player.AddPawn(enemyPawn.GetComponent <Pawn>()); } }