private void Update() { if (NextState == Gal02State.APROACHING_CAULDRON) { RandomMovement rm = GetComponent <RandomMovement>(); if (rm) { rm.StopAllCoroutines(); } } if (NextState != Gal02State.NONE && NextState != CurrentState) { CurrentState = NextState; NextState = Gal02State.NONE; } if (CurrentState == Gal02State.APROACHING_CAULDRON) { MoveTowardsTarget(cauldronTarget.transform.position); } if (CurrentState == Gal02State.CHECKING_POTION) { AudioSource audioS = GetComponent <AudioSource>(); Cauldron c = FindObjectOfType <Cauldron>(); if (!bucketAtCauldron.activeSelf) { // NO WATER NextState = Gal02State.IDLE; audioS.clip = angryTrack; } else if (!c.CheckPotion()) { popupWrong.SetActive(true); popupWrong.GetComponentInChildren <Animator>().SetTrigger("play"); NextState = Gal02State.IDLE; audioS.clip = angryTrack; } else { popupOk.SetActive(true); popupOk.GetComponentInChildren <Animator>().SetTrigger("play"); potionIsReady = true; NextState = Gal02State.DONE; audioS.clip = yesTrack; } } WalkAnimation(); previousPosition = transform.position; }