private IEnumerator CountdownPossession(float duration, TextMeshPro textObject, GameObject possession, EnemyController.EnemyType type) { int totalTime = 0; possession.SetActive(true); petController.Possessed(type); while (totalTime < duration) { totalTime += 1; Debug.Log("Total time " + totalTime); var secondsLeft = duration - totalTime; textObject.text = secondsLeft.ToString() + "s"; yield return(new WaitForSeconds(1f)); } possession.SetActive(false); petController.DePossessed(type); yield break; }