private void spawnInitialSections()
{
for (int i = 0; i < 30; i++) {
GameObject section = GetSectionForDifficulty(CalculateDifficulty(currentLength));
Vector3 pos = Vector3.zero;
if(i > 0) {
GameObject last = currentPath[i-1] as GameObject;
pos = last.transform.position;
pos.z += last.GetComponent<SectionController>().Length/2;
}
GameObject newObject = (GameObject) Instantiate(section, pos, Quaternion.identity);
float newObjectLength = newObject.GetComponent<SectionController>().Length;
pos.z += newObjectLength/2;
currentLength += newObjectLength;
newObject.transform.position = pos;
newObject.layer = LayerMask.NameToLayer ("Terrain");
foreach (Transform child in newObject.transform)
{
child.gameObject.layer = LayerMask.NameToLayer ("Terrain");
}
currentPath.Add(newObject);
}
}