/// <summary>
    /// Do damage to the player and update their health accordingly. If the player's
    /// health drops to zero, the functions subscribed to onDeath are called.
    /// </summary>
    /// <param name="damage">The amount to lower the player's health by</param>
    /// <param name="invincibleTime">The time for which the player cannot be hurt again</param>
    public void doDamage(int damage, float invincibleTime)
    {
        if (currentHealth > 0 && IsVulnerable)
        {
            currentHealth = Mathf.Max(currentHealth - damage, 0);

            //grant invincibility
            StartCoroutine(giveInvincibility(invincibleTime));

            //change health display on canvas
            if (healthDisplay != null)
            {
                healthDisplay.changeHealthDisplay();
            }

            if (currentHealth == 0)
            {
                onDeath?.Invoke(); //apparently this lets it only happen if it's not null
                SceneManager.LoadScene(failSceneName);
            }
        }
    }