OnCollisionEnter() not detecting collision

Hi all,

I’m brand new to unity, and I’ve been meticulously following a tutorial that covers the basics of scripting in C#. However, I’ve gotten to a place where the player object is supposed to react when colliding with the enemy object. I just have it so it prints something so I can make sure it works, but it doesn’t print anything. I’m positive I have the right script – I’ve checked everywhere online, I’ve made sure everything is all set but the collision isn’t being detected. The player object is rigid body, and the enemy object isn’t. What’s going on?

here’s the script:

thanks,
Joseph

You need to add that script to your object player and need have an collider like an box.

I did all of that. I followed the tutorial to the letter. It does collide it just doesn’t register the collision and print the message. Is there anything else I need to do?

Your Enemy is tag with “Enemy”?. because the script work well i test my self.

Yes!!! I haven’t gotten a single script to detect collision yet I’m starting to think my computer is glitching. I can’t even make it print something on collision with anything. It’s like my version of unity doesn’t want to detect collisions at all.

I had the script on the wrong object. Thanks for the help!!!

Face Palm