TOADY FROGGERSON QUEST: 'Better Obstacles' - Solutions

Quest: Toady Froggerson
Challenge: Better Obstacles

Feel free to share your solutions, ideas and creations below. If you get stuck, you can find some ideas here for completing this challenge.

Hey all don’t do what I did when changing this to use object pools like our world tiles and vehicles in order to improve performance.

I used the following to get the children but also to create the obstacle pool.

private void Awake()
{
objectPools = GetComponentsInChildren();
for (int i = 0; i < Random.Range(0, maxObstacleCount); i++)
{
CreateObstacle();
}
}

However spent hours with an error where I couldn’t get it to work and then it dawned on me that some things should not be put in Awake() so I ended up with the following…

private void Awake()
{
    objectPools = GetComponentsInChildren<ObjectPool>();
}

private void Start()
{

    for (int i = 0; i < Random.Range(0, maxObstacleCount); i++)
    {
        CreateObstacle();
    }
}

Hopefully this will stop other people losing their minds!

Kurt

1 Like

Privacy & Terms