Bullets being instantly destroyed

I have a 2D character that holds a weapon. This weapon is positioned inside the character’s collider. When I shoot using the weapon, the bullets are instantly destroyed. I don’t want to disable the collision between the bullet layer and the character. (If I’m not mistaken, I remember there being an option in the Editor that solves this issue.)

You can use Physics2D.IgnoreCollision if you’re looking for just ignoring collisions between two colliders and not looking to mess with the collision layer matrix.

Go to Project Settings > Physics 2D > Layer Collision Matrix