void Awake() { if (models == null || models.Length == 0) { Debug.LogError("No spawnable models found by AgentSpawner!"); } if (Instance == null) { Instance = this; } else { Debug.LogError("Multiple AgentSpawners found in level!"); } }
private void AddAgent() { Agent agent = AgentSpawner.GetAgent(); // Finds a random entrance tile to spawn on // TODO: Only spawn in empty tiles var entrances = grid.GetEntranceTiles(); if (!entrances.Any()) { // No proper entrances found. We'll have to wait until one frees up. return; } var entrance = Utilities.GetRandomEntry(entrances); agent.Goal = FindGoal(entrance); if (agent.Spawn(entrance)) { agents.Add(agent); } }