Quest: Toady Froggerson
Challenge: Spawn A Vehicle
Feel free to share your solutions, ideas and creations below. If you get stuck, you can find some ideas here for completing this challenge.
Quest: Toady Froggerson
Challenge: Spawn A Vehicle
Feel free to share your solutions, ideas and creations below. If you get stuck, you can find some ideas here for completing this challenge.
This one in VehicleSpawner.cs, this is what I got.
I set up a regular Random.Range distribution for the spawn times.
void Update()
{
if(Time.time > nextSpawnTime)
{
SpawnVehicle();
nextSpawnTime = Time.time + Random.Range(minTime, meanTime);
//TODO - Randomly space out the vehicles (Try using something more interesing than just Random.Range(a,b) - maybe exponential distribution for more realistic traffic?)
}
}
void SpawnVehicle()
{
//TODO - Spawn a vehicle from a random object pool.
ObjectPool randomObjectPool = objectPools[Random.Range(0, objectPools.Length)];
randomObjectPool.EnableObjectInPool(0.5f);
}