GameObjects won't collide

I’m new to Unity so it’s probably a really easy thing, but i can’t understand why it isn’t working.
I basically have two Gameobjects, one has a Rigidbody 2d and a Box collider 2D, while the other has only a Box Collider 2D.
The two objects collide when i run the game, but Unity won’t recognize it.

This is the code i used to see if the two objects collide, and the console is always empty.

Is there a problem with the code or with something else?
I already tried a few solutions but i can’t get over this problem:

  • the two objects are on the same layer and can collide.
  • both objects have the IsTrigger option checked.
  • the object with the Rigidbody doesn’t have the ‘isKinematic’ option checked.

You want:

void OnTriggerEnter2D(Collider2D collider) {

not

void onTriggerEnter2D(Collider2D collider) {

Capitalization is important.

Thank you man!