using UnityEngine; using System.Collections; public class SledgeBoost : MonoBehaviour { private static SledgeBoost _instance; // Use this for initialization void Start () { _instance = this; gameObject.SetActive(false); } // Update is called once per frame void Update () { } public static void Boost() { if (!_instance) { return; } _instance.gameObject.SetActive(true); _instance.StartCoroutine(_instance.BoostRoutine()); } private IEnumerator BoostRoutine() { for (int i = 0; i < 20; i++) { Time.timeScale += 0.05f; yield return new WaitForSeconds(0.1f); } yield return new WaitForSeconds(6f); for (int i = 0; i < 20; i++) { Time.timeScale -= 0.05f; yield return new WaitForSeconds(0.1f); } Time.timeScale = 1f; gameObject.SetActive(false); } }