how to inverse this code ?,How can I decrease the enemy's life by the damage value of the "sword" object using ontriggerenter ?

public float EnemyHp_Max = 100;

void OnTriggerEnter(Collider Col)
        if (Col.gameObject.tag == "PlayerSword")
            GameObject.FindGameObjectWithTag("PlayerSword").GetComponent<PlayerDamage>().Damage -= EnemyHp_Max;

in this case the damage value in “sword” object decreases by the enemy’s hp, I need to do the opposite XD

You can reverse it by moving the EnemyHp_Max to the beginning of the line.

EnemyHp_Max -= GameObject.FindGameObjectWithTag("PlayerSword").GetComponent<PlayerDamage>().Damage;

ty guys :smiley: u guys are amazing !