2 objects collide, need to destroy one

Hello, I have 2 objects with rigidbodies attached. One is a character controller (the character I’m moving) and the other is an enemy NPC. When my character collides with this enemy NPC I want him to destroy the NPC. I couldn’t figure out how to do it with OnCollisionEnter so I am trying OnTriggerEnter and I created a capsule collider, attached it to the enemy NPC with “is trigger” checked. Any ideas? Everything I read shows this should be pretty simple but I can’t seem to figure it out. The following script is attached to the enemy NPC:

function OnTriggerEnter(hit : Collider){

  if (hit.gameObject.tag == "Player2") {
    Destroy (gameObject);
  }
}

if im right(not sure) there are a couple of things wrong,or maybe u didnt tell us yet :stuck_out_tongue:

the player(the object that moves) needs to have both a rigidbody and a collider and i think the script needs to be attached to him instead of the npc, try that and let us know if it works.

If the capsule collider is a component added to the NPC, it should work, but if it’s an object childed to the NPC, only the trigger will be destroyed (you should use Destroy(transform.parent.gameObject) in this case).

Another point: the collision character->trigger works fine, but trigger->character is detected only if the trigger has a rigidbody (even a kinematic one): if the trigger is childed to the NPC, make sure it has a kinematic rigidbody (a non-kinematic rigidbody may be moved or rotated by AddForce or AddTorque).