Example #1
0
    //this gets called by the GetDamage Script
    public IEnumerator Damage(int damageReceived)
    {
        count += 1;

        if (currentHealth - damageReceived < 0)
        {
            damageReceived = currentHealth;
        }

        currentHealth -= damageReceived;
        StartCoroutine(healthBar.AnimateHealth(damageReceived));
        //getting called twice for some reason. This could be causing the noanimation/notimer glitch

        if (currentHealth <= 0 && alive)
        {
            StartCoroutine(Death());
        }

        yield return(null);
    }