private void CreateChunk() { LevelChunk chunk = Instantiate(m_LevelChunks[Random.Range(0, m_LevelChunks.Length)], createNextVector3(), Quaternion.identity, m_Transform); m_LastCreatedChunkLength = chunk.GetZLength(); m_CurrentlyLoadedChunks++; m_TotalCreatedChunks++; chunk.name += " " + m_TotalCreatedChunks; }
private void Update() { if (PauseProcess) { return; } LevelChunk chunk = m_Transform.GetChild(0).GetComponent <LevelChunk>(); if (m_SpaceShipBehaviourTransform.position.z > chunk.transform.position.z + (chunk.GetZLength() * 2)) { Destroy(chunk.gameObject); m_CurrentlyLoadedChunks--; } if (m_CurrentlyLoadedChunks < m_MaxLoadedChunks) { if (m_DistanceToGoal < m_GameplayManager.DistanceTravelled()) { PauseProcess = true; m_ObjectSpawner.PauseProcess = true; CreateGoalChunk(); } else { CreateChunk(); } } }