PlayerHealth.TakeDamage C# (CSharp) Method

TakeDamage() public method

public TakeDamage ( float amount ) : void
amount float
return void
    public void TakeDamage(float amount)
    {
        // Decrement the player's health by amount.
        _health -= amount;
    }

Usage Example

Example #1
0
    IEnumerator Attackpeudevie()
    {
        Anim.Play("Attack_02");
        // Reset the timer.
        timer = 0f;
        jouelaniamtiondattaque = true;
        yield return new WaitForSeconds(0.6f);
        timer = 0f;
        // Première partie de l'anim
        if (playerHealth.currentHealth > 0&&enemyHealth.currentHealth>0)
        {
            // ... damage the player.
            playerHealth = target.GetComponent<PlayerHealth>();
            playerHealth.TakeDamage(attackDamage/3);
        }
        yield return new WaitForSeconds(1.4f);
        timer = 0f;

        // Seconde partie de l'anim
        if (playerHealth.currentHealth > 0&&enemyHealth.currentHealth>0)
        {
            // ... damage the player.
            playerHealth = target.GetComponent<PlayerHealth>();
            playerHealth.TakeDamage(attackDamage / 3);
        }
        jouelaniamtiondattaque = false;
    }
All Usage Examples Of PlayerHealth::TakeDamage