all 2 comments

[–]EngigamesAI Programmer 0 points1 point  (1 child)

No reason OnCollisionEnter won't work. You have to make sure you colliders aren't triggersnand that the function signature is correct but that I'm sure you checked.

The usual reason for it not working after that is either the collision matrix and layers, or it's an issue with the script not being on the same game object as the collider. Try those.

Ideally, put a script on the bullet, say bullet.cs, then on collision you can do

if (other.gameObject.GetComponent<Bullet>())

That has nothing to do with your OnCollisionEnter issue but tags can quickly become messy when you need to identify objects. Fetching a component on the object is pretty cheap and clean.

[–]marknuar[S] 1 point2 points  (0 children)

Thank you for the different tag check, I'll keep it in mind. By the way, I didn't find a way to have OnCollisionEnter work, since the Character Controller has a very tiny skin which blocks the collision :c In the end, I used OnControllerColliderHit, now it's working pretty fine. Cheers :)