Trouble killing enemy

I want an enemy to be destroyed when I shoot it.
I’ve tagged my projectile “Projectile”
I’ve placed a Box Collider around my enemy and checked “Is Trigger”
I’ve written the attached script in C# and applied it to my enemy GameObject

Nothing happens when my projectile hits the box collider around my enemy

Help?

Does your projectile or enemy have a rigidbody?

they both do

Add a Debug.Log statement to your OnTriggerEnter, see if it gets called. Check the projectile tag is spelled correctly and has the same uppercase and lowercase characters.

Okay so I added the Debug.Log statement and it seems like the OnTriggerEnter is never getting called
I’ve quadrupled checked the capitalization and spelling of the tag.
I’ve attached the my script currently

I saw that my Debug.Log statement was inside the if statement. I’ve moved it outside the if statement. OnTriggerEnter still isn’t getting called.

I’ve figured out the problem. My projectile didn’t have a box collider on it. Didn’t know it needed one. Thanks for your help.

1 Like