BoxCollider on 2D plane

I have the following objects in a scene:

  • Object A: plane mesh with a BoxCollider, IsTrigger = true
  • Object B: plane mesh with a BoxCollider (IsTrigger = false) and RigidBody (IsKinematic = true)
  • In both objects A and B I override the OnTriggerEnter() method with a simple Debug.Log("Hit: " + other.gameObject.Tag)
  • Both planes are across the XY plane and have Z = 1.

I animate the Object B by updating it’s transform.position within the Update() method. Object B moves towards Object A.
Because they are both on Z = 1, I would expect that they will eventually trigger the OnTriggerEnter() method. But this method is never called on either object.
When I ‘play’ the scene, I clearly see Object B animating all the way over Object A.

Any ideas of what could be going wrong here?

According to the documentation a static trigger hitting a rigid body should cause the method to be called.
I also played around by setting the IsTrigger on all sorts of combinations between the two objects and also tried applying a rigid body to both and none of the items. No luck.

Is the trigger supposed to work for a 2D plane? I also tried adding ‘depth’ to the plane but the OnTriggerEnter still doesn’t get called.

Thanks!

Both objects must have rigid bodies in this scenario.

Thanks for the answer. But per my initial post, I already tried adding a rigid body to both objects but it still doesn’t work.

Also, the documentation at the bottom of the following page states that a kinematic rigidbody collider should generate the events when hitting with a static collider trigger which seems to imply that only one of the objects need to have a rigid body.

Playing a little more with this I noticed the following:
If I initially position both objects near each other so their collider boxes are intersecting and THEN hit ‘play’ on unity, the event for OnTriggerEnter will immediately fire!
However, if I move the objects apart again and THEN hit ‘play’ on unity then my script will animate Object B until it touches Objects A but this time the event won’t fire… :frowning:

I’m animating ObjectB in the Update() method by constantly updating it’s this.transform.position property. Somehow when the objects get close due to the transform being updated the trigger doesn’t seem to be able to detect it…