Example #1
0
 private IEnumerator SlowTime(Health health, GameObject proj)
 {
     isBeingTagged = true;
     Rigidbody2D rb = health.gameObject.GetComponent<Rigidbody2D>();
     if (!isSlowing){
         AudioSource.PlayClipAtPoint(slowTimeHitClip, proj.transform.position, 1f);
         isSlowing = true;
         for (float t=0; t<=1f; t+=Time.unscaledDeltaTime){
             rb.velocity = Vector3.zero;
             Time.timeScale = Mathf.Lerp(1f, .2f, t);
             yield return null;
         }
         Time.timeScale = 1f;
         isSlowing = false;
     } else {
         yield return new WaitForSeconds(1f);
     }
     health.OnImpact();
     Camera.main.GetComponent<ObjectShake>().StartShake();
     isSlowing = false;
     isBeingTagged = false;
 }