Skip to content

Instantly share code, notes, and snippets.

@HassakuTb
Created October 12, 2018 00:37
Show Gist options
  • Save HassakuTb/61deef9533eaa633b0332875ee8a7bfd to your computer and use it in GitHub Desktop.
Save HassakuTb/61deef9533eaa633b0332875ee8a7bfd to your computer and use it in GitHub Desktop.
simple hit stop for Unity
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