private IEnumerator MoveHeads() { while (active) { if (!paused) { if (dead) { targetPos = new Vector3(index * headDistancing, -5, 0); } else { targetPos = new Vector3(index * headDistancing, 0, 0); } transform.localPosition = Vector3.Lerp(transform.localPosition, targetPos, speed * Time.deltaTime); if (Vector3.Distance(transform.localPosition, targetPos) <= 0.1f) { if (index == 2 && !dead) { audioSource.clip = mouthOpen; audioSource.Play(); anim.Play(headOpen.name); } else if (index == 3 && !dead) { audioSource.clip = mouthClose; audioSource.Play(); anim.Play(headClose.name); } while (shiftTimer >= 0) { shiftTimer -= Time.deltaTime; head.UpdateShiftTimer(Mathf.Round(shiftTimer)); yield return(null); } if (waitTime > 0) { shiftTimer = waitTime; } else { shiftTimer = 0; mouthController.ResetObj(); } head.UpdateShiftTimer(Mathf.Round(shiftTimer)); index++; if (index >= maxHeads) { index = 0; transform.localPosition = new Vector3(0, -5, 0); mouthController.ClearObjs(); mouthController.ResetObj(); } } } yield return(null); } yield return(null); }