My Bullet Kill script doesn't work?

I attached this script to my prefab called “Bullet”. Basically, I want that when my bullet hits The enemy (called Agent) The object Agent will be destroyed.

function OnTriggerEnter (hit : Collider){

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

Either your bullets are too fast for collisions to be detected, or you are missing colliders

1 Answer

1

Did you added a collider to your bullet and checked “Is Trigger”?