void Update() { if (touchingPlatform && Input.GetButtonDown("Jump")) { GetComponent <Rigidbody>().AddForce(jumpVelocity, ForceMode.VelocityChange); touchingPlatform = false; } transform.Translate(5f * Time.deltaTime, 0f, 0f); distanceTraveled = transform.localPosition.x; GUIManagerS.SetDistance(distanceTraveled); if (transform.localPosition.y < gameOverY) { GameEventManagerS.TriggerGameOver(); } }
void Update() { if (touchingPlatform && Input.GetButtonDown("Jump")) { GetComponent <Rigidbody>().AddForce(jumpVelocity, ForceMode.VelocityChange); touchingPlatform = false; } transform.Translate(5f * Time.deltaTime, 0f, 0f); distanceTraveled = transform.localPosition.x; GUIManagerS.SetDistance(distanceTraveled); if (transform.localPosition.y < gameOverY) { GameEventManagerS.TriggerGameOver(); } if (SceneManager.GetActiveScene().name == "Level1") { if (transform.localPosition.x >= 527) { acceleration = 0; jumpVelocity = new Vector3((float)0, (float)0, (float)0); GUIManagerS.endLvl(); } } else if (SceneManager.GetActiveScene().name == "Level3") { if (transform.localPosition.x >= 520) { acceleration = 0; jumpVelocity = new Vector3((float)0, (float)0, (float)0); GUIManagerS.endLvl(); } } else if (SceneManager.GetActiveScene().name == "Level3") { if (transform.localPosition.x >= 515) { acceleration = 0; jumpVelocity = new Vector3((float)0, (float)0, (float)0); GUIManagerS.endLvl(); } } }