// ------------------------------------------------------------------- // Navigation public Transform GetPedestrianDestination() { int index = UnityEngine.Random.Range(0, m_Roads.Count); Road road = m_Roads[index]; Transform destination; if (!road.TryGetPedestrianSpawn(out destination)) { return(GetPedestrianDestination()); } return(destination); }
private void SpawnPedestrian(bool reset) { if (reset) { m_PedestrianSpawnAttempts = 0; } int index = UnityEngine.Random.Range(0, m_Roads.Count); Road road = m_Roads[index]; Transform spawn; if (!road.TryGetPedestrianSpawn(out spawn)) { m_PedestrianSpawnAttempts++; if (m_PedestrianSpawnAttempts < m_Roads.Count) { SpawnPedestrian(false); } return; } Agent newAgent = Instantiate(pedestrianPrefab, spawn.position, spawn.rotation, pool.transform).GetComponent <Agent>(); newAgent.Initialize(); }