Hello
I'm trying to create spell prefab with Rigidbody without gravity and BoxCollider with trigger and call it when I press a key, so far so good; The problem starts when in the MonsterDetectCollisions class I try to subtract life points from the creature by implementing the Trigger method because the enemy subtracts 5 by 5 every millisecond and obviously destroys it when I only want to subtract it once, not constantly every millisecond.
private void OnTriggerEnter(Collider other){
if (other.CompareTag("Spell/Sorcerer"))
{
gameObject.GetComponent().TakeDamage(5);
}
}
Does anyone know how I can fix this? I've been hours and I'm desperate
Please!
↧