void Update() { if (gameRunning) { Vector3 dist = Player.transform.position - initialpos; score = dist.x; textbox.text = Mathf.RoundToInt(score).ToString(); if (Mathf.RoundToInt(Player.transform.position.x) == Mathf.RoundToInt(oldpos.x)) { resetTimer += Time.deltaTime; if (resetTimer > timeBeforeReset / 3f) { Player.CameToStop(); } if (resetTimer > timeBeforeReset) { ingameman.PlayerHasStopped(); } } else { resetTimer = 0; } oldpos = Player.transform.position; } }