I am making a melee attack with my game, but I'm stuck in a problem related to using triggers. The enemy NPCs have a sphere collider set on trigger so I will know who is inside their range (radius of 15).
Then, I wrote a simple OnTriggerEnter script to make that when my sword (its collider is set to trigger as well, so it will pass through the enemy) hits an enemy NPC, it will destroy that enemy. The problem is that when I test it, the enemies are destroyed once I enter their sphere collider.
So, is there a way to ignore the trigger from their shpere collider? Or what is the best way to do a melee attack?
NOTE: the destroy function is public in the enemy script and it was called in weapon script attached to the weapon.