void Update() { if (m_start == false) { return; } // score int score = (int)(m_distance * 10); //GetComponentInChildren<Text>().text = "score: " + score; textScore.text = "score: " + score; PlayerScore = score; // set difficulty scrollSpeed = (score / 1000f) + 10f; // play sound score /= 1000; if (score > m_scoreCount) { m_scoreCount = score; audioSource.Play(); } // spawn obsticles if (Time.time > m_next) { int count = Random.Range(1, 4); for (int i = 0; i < count; ++i) { GameObject obstacle = ObstacleSpawner.Instance().SpawnObstacle(); obstacle.transform.position += Vector3.right * (20.0f + i * 2); obstacle.transform.SetParent(transform, true); } m_next = Time.time + 4; } }