OnCollisionEnter does not register

I have a rigidBody with one child and this child has a collider.
I have a script that register collision on the child because it has a specific collision fonction for this collider.

BUT the collision event does not register when colliding against another rigidBody.
If I remove the parent’s rigidBody the collision register.
I dont want the collision script to be on the parent for reasons.

So is this the normal behaviour for OnCollisionEnter() ?

I have the same problem.
I’m not sure why that is, but I also find that surprising.

I added a kinematic rigidbody to the child to fix it for now. But that means I cannot overlap the colliders of the structure or there will be a constant collision occuring.

So weird, I’ve just tested it and it’s working fine on my pc… With no offense… are you sure you only have one rigidbody at your GameObject hierarchy? Child might has another and thats why it’s breaking, no sense if not.

PD: Tested on 2020.1.0, forgot to update…

@rubcc95
Yes the structure is like this:

Parent - rigidbody + collider
          Child - collider + script (with OnColliderEnter() that does not get triggered)

Sincerely not idea what it’s happening, but if you upload the prefab i can play with, thats my free day.

Alright, here it is: (I’m on Unity 2020.1.11)

There’s a scene with 2 balls rolling to the rigidbody structure and only the parent with the rigidbody will call OnCollisionEnter (not the child)

6493061–730205–OnCollisionEnter bug.rar (7.71 KB)

Well I got it. Seems like it works as you expect at 2D Environment, where i was trying cause i had a 2D project opened.

But the “bug” seems to not be a bug. It works as intended, only rigidbody root is able too trigger the collision events… So you can’t fire it though the children gameObject.
But you can get the collider and the gameObject attached to using:

    private void OnCollisionStay(Collision collision)
    {
        Collider colliderWhichTriggered = collision.contacts[0].thisCollider;
        GameObject childWhichTriggered = colliderWhichTriggered.gameObject;
    }

EDIT: Thats your collider, no the other collider :slight_smile: sry

1 Like