public void ShakeCamera(CameraShakeConfiguration shakeConfiguration) { if (AreReferencesAssigned == true) { if (m_CameraShakeRoutine != null) { StopCoroutine(m_CameraShakeRoutine); } m_CameraShakeRoutine = StartCoroutine(ShakeCameraRoutine(shakeConfiguration)); } }
private IEnumerator ShakeCameraRoutine(CameraShakeConfiguration shakeConfiguration) { if (shakeConfiguration != null) { float timer = 0; while (timer < shakeConfiguration.Duration) { float shakeOffset = shakeConfiguration.CalculateCameraShakeOffsetForTime(timer); SetCameraShakeOffset(shakeOffset); timer += Time.deltaTime * m_CameraSpeed; yield return(null); } SetCameraShakeOffset(0); } m_CameraShakeRoutine = null; }