Here is a link to the video/ sound:
As you can see the XP reduction at the end has a sound, and it’s clipping.
Script:
if (shouldRunUpdate)
{
if (UIController.instance.shouldCountDownMagicXP)
{
if (UIController.instance.magicXP > 0)
{
UIController.instance.magicXP -= 1000f * Time.deltaTime;
UIController.instance.magicXPText.text = Mathf.FloorToInt(UIController.instance.magicXP).ToString();
AudioManager.instance.PlaySFX(magicAddSound);
if (UIController.instance.magicXP > 0 && UIController.instance.magicXP < 200)
{
UIController.instance.magicXPIcon.gameObject.GetComponent<UIMagicXPIcon>().anim.SetTrigger("fill");
}
}
else
{
UIController.instance.magicXPText.text = "0";
UIController.instance.shouldCountDownMagicXP = false;
Debug.Log("shouldCountDownMagicXP = " + UIController.instance.shouldCountDownMagicXP);
}
}
else
{
StartCoroutine(UIController.instance.DeathScreenActivator());
}
}
Sound is triggering on line 9. I understand why it’s happening. So I could really use some help thinking of clever ways to fix the choppiness here.
Any thoughts?