hi im trying 2 make it so when my characters sword blade mesh or box collider hits a enemy 5 times the enemy disappears i dont need the enemy 2 play a animation just 2 disappear my character already using animations for the attacking but i would like if possible 2 have it so only does damage if 1 of the attack keys are used but if u dont know how thats fine ether way is good my character is using this script for the animations
You probalby want to create an enemyscript and check if the enemy is hit by the sword. If it’s hit 5 times you can destroy the enemy.
try to attach this into your enemyscript (not tested)
var _collider : BoxCollider;
var health : float = 5;
_collider = GetComponent(BoxCollider);
function OnCollisionEnter(col : Collision)
if(col.gameObject.tag == "Sword")
if(health <= 0)
Note: you will need to add a tag (Sword) to the sword. And if you are not using a BoxCollider on the enemy, replace “BoxCollider” with your collidertype. (You will need a collider on the enemy just to make it clear)
- Make a variable that keeps track of how much health the enemy has
- Give the variable to the enemy, dependent on collision with sword (might I suggest that the enemy just isn’t detecting collision?)
- Make the enemy destroy itself if health variable==0.
I didn’t add code because it seems that you can code yourself. I can add code if you want me to, though.