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(); }
private void SpawnRoadVehicle(bool reset) { if (reset) { m_RoadVehicleSpawnAttempts = 0; } int index = UnityEngine.Random.Range(0, m_Roads.Count); Road road = m_Roads[index]; VehicleSpawn spawn; if (!road.TryGetVehicleSpawn(out spawn)) { m_RoadVehicleSpawnAttempts++; if (m_RoadVehicleSpawnAttempts < m_Roads.Count) { SpawnRoadVehicle(false); } return; } Vehicle newVehicle = Instantiate(vehiclePrefab, spawn.spawn.position, spawn.spawn.rotation, pool.transform).GetComponent <Vehicle>(); newVehicle.Initialize(road, spawn.destination); }