SpeedUp.cs 473 B

1234567891011121314151617181920212223242526272829
  1. using UnityEngine;
  2. using System.Collections;
  3. public class SpeedUp : MonoBehaviour
  4. {
  5. private static SpeedUp Instance;
  6. void Start ()
  7. {
  8. Instance = this;
  9. }
  10. public static void StartRace()
  11. {
  12. Time.timeScale = 1;
  13. Instance.StartCoroutine(Instance.Up());
  14. }
  15. private IEnumerator Up()
  16. {
  17. while (transform)
  18. {
  19. yield return new WaitForSeconds(1f);
  20. Time.timeScale += 0.001f;
  21. }
  22. }
  23. }