There are four things I can think of which need to happen so that
OnTriggerEnter gets called:
- The two objects’ colliders need to actually be overlapping. Just because their rendered pixels are overlapping, doesn’t mean their colliders are overlapping. This can be checked in the editor. Their colliders are indicated with a green outline in the
Scenetab. If you don’t see anything, make sure the button labeled
Gizmosis turned on.
- The two objects need to be in physics layers which are set to collide with each other. You can check this in
Edit > Settings > Physics2D > Layer Collision Matrix.
- Both objects need to have Rigidbody2D components attached. Make sure these aren’t Rigidbody components, as those are for 3D physics.
- The object which contains the
OnTriggerEnter2Devent needs to have
isTrigger = true.