Issue with setting up collisions and triggers

So i’m making this little 2D game, and i’m having issues registering collisions.
I have a character with a BoxCollider2D and some walls with BoxCollider2D as well. In order to register the collision through code (void OnEnterCollision2D()) one of the components needs to have a rigidbody component, but my character has a rigidbody component, and the collision between the two is not being called in code.
I tried adding a rigidbody component to the walls, but then if i freeze all the axis, it’ll say that i might as well not have that rigidbody component.
Is there another way to make this work?

Change OnEnterCollision2D to OnCollisionEnter2D.

MonoDevelop doesn’t notice this error because OnCollisionEnter2D and other event functions are technically user-defined functions; there isn’t a base method here you’re overriding (Unity has a few tricks under the hood to call these functions, but I won’t go into it here). A side effect of this is that you have to be extra-careful to use the right spelling and parameters whenever you use them, because you’ll never get a warning that you’ve declared the function wrongly.