- Home /
How do I apply damage to the enemy ai using melee weapon OnControllerColliderhit
I want to take 10 damage amount and using OnControllercolliderhit a melee weapon . I am having some issues . The enemy is not taking any damage . Here is my apply damage script :
using UnityEngine; using System.Collections; using Opsive.ThirdPersonController.Wrappers;
public class ApplyDamage : MonoBehaviour {
LayerMask m_AttackLayer;
Healthbar healthbar;
void Start(){
healthbar = FindObjectOfType<Healthbar>();
if (healthbar == null) {
Debug.LogError("Healthbar class is not found in scene!");
}
}
void OnControllerColliderHit(ControllerColliderHit) { if (hit.gameobject.tag == "Enemy") {
healthbar.SendMessage("I am hit.", health, SendMessageOptions.DontRequireReceiver);
} }
}
Your answer
Follow this Question
Related Questions
How do I apply damage to enemy ai in unity c# 0 Answers
Damaging Enemy strangely not working. 0 Answers
Applying Damage 5 Answers
JS script for applying damage to player when within a certain proximity to the Enemy. 2 Answers
ApplyDamage Error 0 Answers