Hi guys, I have a simple script here attached to a melee weapon. It isn’t dealing any damage when I hit an enemy:
var damage : float;
var force : float;
function OnTriggerEnter (col : Collider) {
if(col.Tag == "Enemy")
GetComponent("CharacterDamage").hitPoints -= damage;
Debug.Log("Collided!!!!!");
}
Can someone give me an idea what I’m doing wrong? I have a box collider attached to the melee weapon and a sphere collider on the enemy that is set to trigger.
HEY GUYS! members and variables tend to start with lower case. Functions and Classes start with Upper Case. Second question this minute with this same type of problem
Ok I have revised the script but it still isn’t working. The debug.log statement isn’t even being called. Here’s the script now:
var damage : float;
var force : float;
function OnControllerColliderHit(hit : ControllerColliderHit){
if(hit.gameObject.CompareTag == "Enemy")
GetComponent("CharacterDamage").hitPoints -= damage;
Debug.Log("Collided!!!!!");
}