Mesh collider trigger against compound collider rigidbody

I have a problem that isn’t written anywhere in the docs.

Object A has a rigidbody and several child objects with; a boxcollider, 4 wheelcolliders.
Object B has a mesh collider which is a trigger, and a script to handle OnTriggerEnter events.

When these collide, no message is send. When I turn the mesh collider of object B into a boxcollider, I do receive a message.
I tried turning on ‘convex’ on the mesh collider, but that doesn’t help.

What is going on and what to do? I really need the mesh collider.

Hello,

Have you checked this?
http://col000r.blogspot.com/2009/06/unity-triggers-and-colliders.html

hope it helps :slight_smile:

Hi and thanks. No, I didn’t read it, but it doesn’t help me any further either. My collider has a rigidbody and does move. The trigger doesn’t have one, and doesn’t need one.

The problem is the combination of a trigger and a mesh collider. If I only change the mesh collider into a box collider, everything works fine. Same for the trigger.

But how is that supposed to be normal? If I turn off the trigger, the two colliders do collide and bounce and everything. So if that works, why does the trigger not work then?

Try adding a rigidbody to the MeshCollider object (you’ll probably want to make it kinematic).

Thanks for the suggestion. I tried that as well, doesn’t make any difference.

Are you getting any error messages or is it just not detecting the collision with OnTriggerEnter?

It’s just not detecting collision. No bug whatsoever. I have a script that calls debug.log() with some text in the OnTriggerStay() event, of which I am sure works (when I change the mesh to a box collider, it works, and also when it gets hit by a single collider, instead of compound collider).

Should I consider this as a bug, or am I doing things the wrong way?

I’m not sure if it is a bug or a known “missing” feature from the physics. Try contacting support@unity3d.com about this - they might be able to suggest something.

It’s definitely a bug.
I discovered what goes wrong. The problem lies within the child-parent relation. When the child is moved in world space, as a result of it’s parent movement, the trigger-test is not executed. When the child itself is moved, the check is done.
My solution is a script which does a translate of vector3.zero in the update method.

That’s very interesting - can you file a bug report on this?

What do you mean with that exactly?

Well, if you’ve discovered a bug in Unity, it will help the developers out if you report it to them. There is an application called Report Bug in the folder with the Unity app that you can use to do this. You can also use it to request features or note mistakes in the documentation, etc.

Ah I see. Yes, I will do so.

I have the exact same problem in my car project, but I couldn’t understand what you meant by “translate of vector3.zero”. Can you please give some more details?

I am having the same problem, but I do not think the problem is in the trigger-test not executing. I think when the parent object rotates, the internal calculations on the child colliders are wrong so the colliders end up in the wrong place, even though the gizmos look correct.

In my case, the child’s collider ends up hitting another collider on the same game object causing the physics to go bersek. Same underlying problem, I think.

Unity, is there any update on this?

You should only have one rigid body and it must be attached to the parent. Never have colliders attached to children of children.

I have build the colliders consistent with the example in ‘composite colliders’ and do not have any on children of children. Problem persists and it is getting annoying having to work around it.

Are you attaching your on collision script to the parent? OnCollisionEnter will give you the collisionInfo. Tag them as needed.

Has a bug report actually been filed for this? It’s a really annoying bug, and set me back a few hours at work today :frowning: