public IEnumerator FinishNewTrail() { TrailComp trailComp = currentTrail.GetComponent <TrailComp> (); yield return(new WaitForSeconds(0.01f)); trailComp.name = "Trail" + currentTrailBeingCreated.ToString(); trailComp.trailEnd = trailComp.wps [trailComp.wps.Count - 1]; trailComp.trailNumber = currentTrailBeingCreated; // trailComp.wps = currentTrail; trailComp.trailDifficulty = currentTrailDifficultyLevel; trailComp.StartCoroutine(trailComp.ScanArea()); /* foreach (GameObject go in currentTrail) { * go.transform.parent = newTrail.transform; * }*/ foreach (GameObject go in currentBorders) { go.transform.parent = currentTrail.transform; } foreach (GameObject go in currentColliders) { DestroyObject(go); //go.transform.parent = newTrail.transform; } yield return(new WaitForSeconds(0.1f)); currentWayUpPosList.Reverse(); GameObject newWayUp = Instantiate(emptyPrefab, currentWayUpPosList [0], transform.rotation); newWayUp.name = "WayUp" + currentTrailBeingCreated.ToString(); newWayUp.tag = "WayUpStart"; newWayUp.AddComponent <WayUpComp> (); BoxCollider bComp = newWayUp.AddComponent <BoxCollider> (); bComp.isTrigger = true; Rigidbody rigidC = newWayUp.AddComponent <Rigidbody> (); rigidC.useGravity = false; int w = 0; foreach (Vector3 v in currentWayUpPosList) { if (w >= 1) { GameObject newWp = Instantiate(emptyPrefab, v, transform.rotation); newWp.transform.parent = newWayUp.transform; newWp.tag = "wayUpWP"; newWayUp.GetComponent <WayUpComp> ().wps.Add(newWp); BoxCollider boxComp = newWp.AddComponent <BoxCollider> (); boxComp.isTrigger = true; Rigidbody rigidComp = newWp.AddComponent <Rigidbody> (); rigidComp.useGravity = false; if (w == currentWayUpPosList.Count - 1) { newWp.name = "WayUpFinish"; } } w += 1; } yield return(new WaitForSeconds(0.25f)); SetTrailCreationModeOff(); currentTrailBeingCreated += 1; trailComp.isFinished = true; trailComp.StartCoroutine(trailComp.ScanArea()); StartToSpawnSkiers(12); }