public void SpawnNpc(GameObject randomPrefab, List <NpcAccessPoint> compatibleDestinations) { if (randomPrefab == null) { throw new System.ArgumentNullException("randomPrefab"); } if (compatibleDestinations == null || compatibleDestinations.Count <= 0) { throw new System.ArgumentNullException("compatibleDestinations"); } Debug.Log(string.Format("Spawned an NPC at: {0}", Time.time)); GameObject npc = Instantiate(randomPrefab, transform.position, transform.rotation) as GameObject; _spawningNpc = npc.GetComponent <NpcType>(); if (_spawningNpc != null) { _spawningNpc.Spawn(this); } else { Debug.LogError("An NPC is missing its NpcType component"); } AINavigator npcNav = npc.GetComponent <AINavigator>(); if (npcNav != null) { GameObject destination = compatibleDestinations[Random.Range(0, compatibleDestinations.Count - 1)].gameObject; npcNav.Start(destination); } else { Debug.LogError("An NPC is missing its AINavigator component"); } }