This melee damage detector won't work...

Okay, I’m still not sure what doesn’t work but I know that the objects are not detecting the trigger for some reason so I’ll just ask if there’s anything wrong with these few lines.

function OnTriggerEnter(that : Collider) {
 Debug.Log("OnTriggerEnter() was called");

This should send a message to show that OnTrigger was called but it won’t for some reason, it won’t happen. This is perplexing because in a script I have that monitors health, the exact same line is used and works perfectly on the player, but when I put this on another object set to “isTrigger” it does nothing.

For OnTrigger to work, the object with this script must be set to “isTrigger”. Otherwise use OnCollisionEnter instead


OH, got it:

change if(Input.GetButtonDown(“Hit”)…



GetButtonDown only returns true the first frame the button is pressed


Since the question has now changed, here’s the new answer-

If BOTH objects are set to isTrigger, one of them will need a rigidbody as well… OR, just use OnCollisionEnter instead

note the section on triggers