You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
783 B

using System.Collections;
using UnityEngine;
public class CamSlowMotionDelay : MonoBehaviour {
public float slowMotionTimeScale = .2f;
public void StartSlowMotionDelay(float duration){
StopAllCoroutines();
StartCoroutine(SlowMotionRoutine(duration));
}
//slow motion delay
IEnumerator SlowMotionRoutine(float duration) {
//set timescale
Time.timeScale = slowMotionTimeScale;
//wait a moment...
float startTime = Time.realtimeSinceStartup;
while (Time.realtimeSinceStartup < (startTime + duration)) {
yield return null;
}
//reset timescale
GameSettings settings = Resources.Load("GameSettings", typeof(GameSettings)) as GameSettings;
if (settings != null) {
Time.timeScale = settings.timeScale;
} else {
Time.timeScale = 1;
}
}
}