UnityPlatformer.CharacterHealth.Damage C# (CSharp) Method

Damage() public method

Try to Damage the Character triggers onDamage triggers onDeath NOTE this won't trigger onHurtCharacter
public Damage ( int amount = 1, CharacterHealth causer = null ) : bool
amount int
causer CharacterHealth
return bool
    public bool Damage(int amount = 1, CharacterHealth causer = null) {
      if (amount <= 0) {
        Debug.LogWarning("amount <= 0 ??");
      }

      if (IsInvulnerable()) {
        Debug.Log(this.name + " is invulnerable, ignore damage");

        if (onDamage != null) {
          onDamage();
        }

        if (onImmunity != null) {
          onImmunity();
        }

        return false;
      }

      health -= amount;

      // do not set invulnerable a dead Character
      if (health > 0) {
        SetInvulnerable(invulnerabilityTimeAfterDamage);
      }

      if (onDamage != null) {
        onDamage();
      }

      if (onInjured != null) {
        onInjured(null, causer);
      }

      if (health <= 0) {
        Die();
      }

      return true;

    }
    /// <summary>

Same methods

CharacterHealth::Damage ( int amount, DamageType dt, CharacterHealth causer = null ) : bool
CharacterHealth::Damage ( Damage dmg ) : void