I have two game objects, a player and a monster. My problem is when I run into or otherwise contact the monster(with my character’s weapon), it’s HP drains rapidly which is NOT what I want.
Ideally I would like to be able to smack a monster once and cause damage once. Not damage upon contact. I have a trigger collider set to the weapon, and on collision it causes the monster to be damaged. The question is, how would I go about making it so that 1) the damage is only inflicted once and 2) Only causing damage when I swing the sword and not any other time?
I would be okay with some kind of temporary invincibility as well. But I would prefer to be able to combo strike a monster.
No. I'm using it correctly. The problem is that it fires way too often. When the weapon brushes against the monster it starts draining HP. I've also tried using variables(booleans) to limit how often it works, to no avail.
– TheEmeralDreamerWell, if you use booleans you can set up attack so that 1- trigger = inflict damage, set up boolean variable 'donthitagainuntilweaponhasleftthetrigger' 2- in 'inflict damage' check if donthitagainuntilweaponhasleftthetrigger is true 3- Ontriggerexit set donthitagainuntilweaponhasleftthetrigger to false this WILL only inflict damage once the weapon has left the trigger and entered it again. If you want to artificially alter the attack rate, you have to use timers so on attack set lastattack = Time.time and verify if Time.time - lastattack > myattacktimer to inflict damage.
– roamcel