Swrod will not cause damage to AI

cangcloud

Member
I created the Sword weapon, but I found that Sword cannot cause damage to the AI. I tried to attack the AI with Sword, but the AI was not harmed and the health value did not change. When I attacked the AI with a rocket launcher... the AI died. I don't know what went wrong, see the video I recorded for the specific situation.
 
Did you check the Melee Weapon Properties on the weapon to make sure it has a Collider assigned to it? Also check the Impact Layers on the Melee Weapon component.
 
The sword will collide with the first collider it hits, so if your AI has multiple colliders/sub-colliders then the sword might hit one of those first without detecting the AI at all. E.g. if the AI has a shield in front of it, or armour with a collider, etc etc. I'd recommend putting a Debug.Log at the top of MeleeWeapon.HitCollider to log the values of hitGameObject and hitCollider to check if the sword is actually hitting the collider you expect.
 
Top