public static void ShakeCamera(float shakeIntensity, float intervalTime) { Action newAction; HookUpdater.Create(newAction = new Action(() => { if (intervalTime <= 0) { return; } intervalTime -= Time.unscaledDeltaTime; float[] floatArray = new float[2] { +1, -1 }; int randomIndexX = UnityEngine.Random.Range(0, 2); int randomIndexY = UnityEngine.Random.Range(0, 2); float randomX = floatArray[randomIndexX]; float randomY = floatArray[randomIndexY]; Vector3 randomDirection = new Vector3(randomX, randomY) * shakeIntensity; Camera.main.transform.position += randomDirection; shakeIntensity -= .07f; })); }
private void Awake() { if (instance != null) { Destroy(gameObject); } else { instance = this; } }