The summary: collisions and triggers are not working as I expected. (I’ve posted on Unity Answers, but no answer, yet, so I figured I’d try here!)
So, in 3D, pre-4.2, I had an object that only had a BoxCollider. I click to spawn an explosion object that had a Kinematic Rigidbody and a SphereCollider, which expands in radius with an animation. Both marked as triggers. OnTriggerEnter is correctly called on both objects.
I made the switch to use 2D physics with 4.3. I have an object that only has a BoxCollider2D, and I spawn objects that have a Kinematic Rigidbody2D and a CircleCollider2D, which again expand with an animation. Both marked as triggers. OnTriggerEnter2D is never called.
After some experimenting, I found that the only way I could get OnTriggerEnter2D to execute is if I DON’T set that Rigidbody2D as kinematic. The same holds true for OnCollisionEnter2D when the objects aren’t triggers.
As I said on that Unity Answers post, I went over the table at the bottom of this page again, and, unless there’s an intended difference between 3D and 2D physics, it should work as I want it to.
After changed all 3D physics collider and rigidbody to 2D. ontrigger/oncollision don’t work.
It only happen on kinematic rigidbody.
I run a test scene testing both 3D and 2D trigger with kinematic rigidbody. only 3D trigger work.
likewise, the only thing working that I can see at the moment is use 3D collision, or don’t use 2D kinematic rigid bodies. Hopefully they’re working on a fix for kinematic 2D collisions!
Just a question, are you trying to get 2 kinematic rigid bodies to collide with each other? If so, it can’t be done AFAIK. I am not an expert by any means though. If this isn’t what you were trying to do, then completely ignore this response.
No, I’m trying to get two Kinematic Rigidbody Trigger Colliders to call the OnTriggerEnter2D function.
Or, rather, a Kinematic Rigidbody Trigger Collider hitting any trigger at all, it just won’t work. It has to be non-kinematic. Which is counter to what’s in this table at the bottom of this page: Unity - Manual: Box collider component reference
Actually, he’s right, Kinematic Rigidbody Colliders (as in, non-Triggers) aren’t supposed to collide. The page I linked above (I’ll just link it again: Unity - Manual: Box collider component reference) shows which collisions/triggers are supposed to work.
If it does work in 3D, it’s not actually supposed to. Unless that page is out of date, I suppose, which is entirely possible!
the place it seems to fall down for me, is detecting trigger events when a kinematic rigid body intersects any trigger collider in the scene, or trigger events when a kinematic trigger rigid body intersects with any collider. Both off these cases are currently not working in 2D for me.
Colliders on Kinematic bodies can only collide with colliders on Dynamic bodies. It doesn’t matter whether the collider is set to be a trigger or not. This is determined by Box2D itself.
Box2D imposes the following valid body-type collisions:
Static with Dynamic
Dynamic with Static, Dynamic Kinematic
Kinematic with Dynamic
Yeah it’s triggers (or sensors, apparently!) that I’m most interested. Still, thanks for the info, guess it’s a limitation of Box2D. Don’t know why I didn’t consider that. Oh well!
Technically there is no such thing as a “trigger”, it’s obviously just a collider that is in a trigger “mode” so the same rules apply. The only difference being whether it actually causes forces to be applied to the colliding objects, how it is reported in callbacks and if it constitutes mass to the rigid-body.
Unfortunately, it would be difficult to change this behaviour in Box2D.
(As an aside, every single one of your posts, across multiple threads, appears to me as a giant empty post with tons of white space. I have to reply with quote to even see what you’re saying.)
Yeah I’m not too sure! I’m like 99% certain it’s not your fault. I noticed it with a different Unity developer’s post, too. It must be a weird bug with Chrome or some extension I have. Although I don’t think I have any that would affect these forums, so… Yeah I’m not too sure!
I’m having this problem in Safari on my iPhone. Weirdly enough, it was only after I logged in; I could see them fine before logging in.
Anyway, I’ve been having problems with triggers myself and I just wanted to clarify things:
Two 3D kinematic rigidbodies won’t send collide messages, but they WILL send trigger messages.
Two 2D kinematic rigidbodies won’t send trigger messages, either.
Is the fact that the two function differently by design or a bug?