public void GenerateLevel(int level) { Destroy(currentGoal.gameObject); //order is important; we need the goal for the ball SpawnGoal(); //generate new ball position float ballPosX = Random.Range(-0.5f * fieldWidth, 0.5f * fieldWidth); ballPosition = new Vector3(ballPosX, ballPosY, ballDistance); if (useObstacles) { obstacleManager.ResetObstacles(); obstacleManager.GenerateObstacles(level); } }