Created
October 12, 2018 00:37
-
-
Save HassakuTb/61deef9533eaa633b0332875ee8a7bfd to your computer and use it in GitHub Desktop.
simple hit stop for Unity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using UnityEngine; | |
using System.Collections; | |
public class HitStopHandler : MonoBehaviour { | |
public void HitStop(float stopTime, Action onResume) | |
{ | |
StartCoroutine(HitStopCoroutine(stopTime, onResume)); | |
} | |
private IEnumerator HitStopCoroutine(float stopTime, Action onResume) | |
{ | |
float timeScale = Time.timeScale; | |
Time.timeScale = 0f; | |
yield return new WaitForSecondsRealtime(stopTime); | |
Time.timeScale = timeScale; | |
if (onResume != null) onResume(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment